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