driveClient function
- @Riverpod(keepAlive: true)
- dynamic ref
A provider for the Google Drive API client.
This provider is a keep-alive provider, meaning that it will not be disposed when no longer used. It is used to provide the DriveApi instance to the DriveApiService class. It is used to interact with Google Drive.
Implementation
@Riverpod(keepAlive: true)
Future<DriveApi> driveClient(DriveClientRef ref) async {
final client = await auth.clientViaServiceAccount(
auth.ServiceAccountCredentials.fromJson(
isDev ? Env.driveCredentialsDev : Env.driveCredentialsProd,
),
[
DriveApi.driveScope,
DriveApi.driveFileScope,
],
);
ref.onDispose(() => client.close());
return DriveApi(client);
}