cloud_sync_google_drive_adapter 0.0.1-rc.2
cloud_sync_google_drive_adapter: ^0.0.1-rc.2 copied to clipboard
A Flutter plugin for integrating Google Drive cloud sync functionality.
CloudSyncGoogleDriveAdapter #
A Google Drive-based implementation of the SyncAdapter interface from the cloud_sync package.
This adapter enables two-way synchronization of metadata and string-based detail content with the user's Google Drive, using file descriptions and binary content for storage.
β¨ Features #
- π Syncs metadata (
SyncMetadata) and string detail content (String) via Google Drive files. - π₯ Fetches a list of metadata from Drive.
- π€ Uploads new files or updates existing ones using metadata ID.
- πΎ Stores detail as file content and metadata as file description.
- π¦ Operates in
appDataFolderby default to isolate app-specific files.
π¦ Installation #
Add dependencies in your pubspec.yaml:
dependencies:
cloud_sync: ^latest
cloud_sync_google_drive_adapter: ^latest
google_sign_in: ^latest
π Usage #
import 'package:cloud_sync_google_drive_adapter/cloud_sync_google_drive_adapter.dart';
import 'package:http/http.dart' as http;
import 'your_models/sync_metadata.dart'; // Your custom metadata model
final adapter = CloudSyncGoogleDriveAdapter<MyMetadata>.fromClient(
client: authClient, // Use authenticated client
metadataToJson: (meta) => jsonEncode(meta.toJson()),
metadataFromJson: (json) => MyMetadata.fromJson(jsonDecode(json)),
);
To create with a client only:
final adapter = CloudSyncGoogleDriveAdapter<MyMetadata>.fromClient(
client: authClient,
metadataToJson: ...,
metadataFromJson: ...,
);
π Class Overview #
class CloudSyncGoogleDriveAdapter<M extends SyncMetadata>
extends SerializableSyncAdapter<M, String>
spaces: Google Drive spaces to use (default:'appDataFolder')fileName: Drive file name used to identify synced data- Implements:
fetchMetadataList()β List of files with metadata in descriptionsfetchDetail()β Decoded file contentsave()β Create or update file in Drive
β When to Use #
- βοΈ You want cloud backup or multi-device sync.
- π Youβre storing encrypted data or structured content.
- π± Perfect for apps syncing notes, tasks, logs, or media references.
π License #
MIT (or your projectβs license)
π Related #
cloud_syncβ Core sync abstractiongoogleapisβ Google Drive API