Skip to main content

flutter_offline_sync_pull 0.1.0 copy "flutter_offline_sync_pull: ^0.1.0" to clipboard
flutter_offline_sync_pull: ^0.1.0 copied to clipboard

Pull coordinator for offline-first apps: paginated list sync, entity-batch detail sync, and Drift-backed checkpoints. Complements flutter_offline_sync_core (write queue) on the read side.

flutter_offline_sync_pull #

pub package license

Pull coordinator for offline-first Flutter/Dart apps. Complements flutter_offline_sync_core on the read side: paginated list sync, entity-batch detail sync, and Drift-backed checkpoints.

flutter_offline_sync_core = push write queue.
flutter_offline_sync_pull = pull ingest orchestration.

Docs: Pull guide · GitHub

Install #

dependencies:
  flutter_offline_sync_pull: ^0.1.0

Most Flutter apps should depend on flutter_offline_sync_pull_flutter instead (re-exports this package).

Quick start #

import 'package:flutter_offline_sync_pull/flutter_offline_sync_pull.dart';

final registry = PullFeatureRegistry()
  ..register(
    PullFeature(
      name: 'documents',
      steps: [
        PaginatedListPullStep(
          key: 'list',
          pageSize: 10,
          handler: DocumentListPullHandler(dio, appDb.documentsDao),
        ),
      ],
    ),
  )
  ..register(
    PullFeature(
      name: 'workflow',
      steps: [
        PaginatedListPullStep(
          key: 'list',
          pageSize: 20,
          handler: WorkflowListPullHandler(dio, appDb),
        ),
        EntityBatchPullStep(
          key: 'detail',
          dependsOn: ['list'],
          batchSize: 10,
          idSelector: (_) => appDb.workflowsDao.idsMissingDetail(),
          handler: WorkflowDetailPullHandler(dio, appDb),
        ),
      ],
    ),
  );

final coordinator = PullCoordinator(
  db: PullDatabase(),
  registry: registry,
);

await coordinator.runFeature('documents');
await coordinator.runAll();

Step types #

Type Use for
PaginatedListPullStep page=1&limit=10 style list APIs
EntityBatchPullStep Per-id detail/stages; idSelector returns ids still missing locally

Handlers call your API and upsert into your AppDatabase tables. This package only stores checkpoints in flutter_offline_sync_pull.sqlite.

With flutter_offline_sync (push + pull) #

await engine.syncAll();        // flutter_offline_sync_core / flutter
await pullCoordinator.runAll(); // flutter_offline_sync_pull

For Workmanager + connectivity on the pull side, use flutter_offline_sync_pull_flutter (runBackgroundPull, FlutterPullCoordinator). See packages/flutter_offline_sync_pull_flutter/example.

Activity stream #

coordinator.isPulling;
coordinator.isPullingStream;

Example #

cd packages/flutter_offline_sync_pull/example
flutter run

Demonstrates paginated document list sync and workflow list + entity-batch detail sync with fake handlers. See example/lib/store_and_handlers.dart.

Codegen #

dart run build_runner build --delete-conflicting-outputs
0
likes
140
points
--
downloads

Documentation

Documentation
API reference

Publisher

verified publisherlidhin.com

Pull coordinator for offline-first apps: paginated list sync, entity-batch detail sync, and Drift-backed checkpoints. Complements flutter_offline_sync_core (write queue) on the read side.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#offline #sync #pull #drift #flutter

License

MIT (license)

Dependencies

drift, meta, path, path_provider

More

Packages that depend on flutter_offline_sync_pull