locorda_gdrive 0.5.2 copy "locorda_gdrive: ^0.5.2" to clipboard
locorda_gdrive: ^0.5.2 copied to clipboard

Google Drive backend for Locorda BYOB sync — the recommended default backend. Stores sync data in App Data Folder or a visible Drive folder using Google Sign-In (OAuth2).

example/README.md

locorda_gdrive Examples #

This package provides Google Drive backend integration for locorda.

The easiest way to integrate Google Drive is via the locorda_dev code generator, which generates all worker boilerplate automatically.

1. Add dependencies #

# pubspec.yaml
dependencies:
  locorda: ^<version>
  locorda_gdrive: ^<version>
  # ... other locorda packages

dev_dependencies:
  build_runner: ^<version>
  locorda_dev: ^<version>

2. Run the code generator #

dart run build_runner build

This generates:

  • init_locorda.g.dartinitLocorda() convenience wrapper with auto-configured worker setup, mapper, and config
  • worker_generated.g.dartgeneratedWorkerSetup() worker entry point that assembles all package adapters

3. Use in main.dart #

import 'package:locorda_gdrive/locorda_gdrive.dart';
import 'package:locorda_drift/locorda_drift.dart'; // example storage backend
import 'init_locorda.g.dart'; // generated

void main() async {
  final locorda = await initLocorda(
    storage: DriftMainHandler(),
    remotes: [
      // App Data Folder (private, recommended)
      await GDriveMainIntegration.create(),

      // Or: visible folder in user's My Drive
      // await GDriveMainIntegration.create(
      //   config: GDriveConfig.visibleFolder(appFolderName: 'MyApp'),
      // ),
    ],
  );
  // use locorda ...
}

No worker setup code is needed — the generator handles it.


Manual Setup (without code generation) #

Use this approach when you need full control over worker configuration or are not using locorda_dev.

Main thread (lib/main.dart) #

import 'package:locorda/locorda.dart';
import 'package:locorda_gdrive/locorda_gdrive.dart';

final locorda = await Locorda.create(
  workerSetup: setupWorkerEngine, // your worker setup function
  storage: DriftMainHandler(),
  remotes: [await GDriveMainIntegration.create()],
  config: generateLocordaConfig(),      // from your locorda_config.g.dart
  mapperInitializer: initRdfMapper,     // from your init_rdf_mapper.g.dart
);

Worker thread (lib/worker.dart) #

import 'package:locorda_worker/worker.dart';
import 'package:locorda_gdrive/worker.dart';
import 'package:locorda_drift/worker.dart'; // example storage backend

Future<WorkerParams> setupWorkerEngine() async => WorkerParams(
  storages: [DriftWorkerHandler()], // required
  remotes: [
    GDriveWorkerHandler(), // receives GDriveConfig automatically from main thread
  ],
);

For a complete working example, see the Personal Notes App.

For storage modes (App Data Folder vs. visible folder), layouts, and OAuth2 setup, see the package README.

0
likes
160
points
150
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Google Drive backend for Locorda BYOB sync — the recommended default backend. Stores sync data in App Data Folder or a visible Drive folder using Google Sign-In (OAuth2).

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#google-drive #authentication #oauth2 #offline-first #crdt

License

MIT (license)

Dependencies

crypto, flutter, flutter_localizations, google_sign_in, google_sign_in_web, googleapis, http, intl, locorda_core, locorda_flutter_core, locorda_rdf_core, locorda_ui, locorda_worker, logging, path, rxdart

More

Packages that depend on locorda_gdrive