Skip to content

Architecture ​

Technical map of how the packages sit beside your app. Vocabulary: Core concepts.

High-level flow ​

Component responsibilities ​

PieceResponsibility
Repository / UIEnqueue jobs; read App DB for screens
SyncEngineDrain outbox; deps; retry; conflicts
SyncDatabasePersist jobs/steps
PullCoordinatorRun features/steps with caps
PullDatabasePersist pull checkpoints
Your handlersHTTP + upsert App DB

Three databases ​

Never merge these in documentation or mental model:

DatabaseFile (default)OwnerStores
AppDatabaseapp.sqlite (your choice)Your appDocuments, orders, settings, …
SyncDatabasesync_core.sqliteflutter_offline_sync_coreOutbox jobs and steps
PullDatabaseflutter_offline_sync_pull.sqliteflutter_offline_sync_pullPull checkpoints only

Packages never open your AppDatabase. Handlers you write call your DAOs/local datasources.

Push lifecycle ​

text
JobBuilder.enqueue
  → SyncDatabase (pending)
SyncEngine.syncAll / runJob
  → resolve handlers by taskType
  → execute steps (dependsOn order)
  → success output | failure | conflict

Pull lifecycle ​

text
PullCoordinator.runFeature / runAll
  → load/create checkpoint
  → PaginatedListPullStep and/or EntityBatchPullStep
  → handler.fetch → upsert App DB
  → update checkpoint (page, hasMore, status)

Reconnect order ​

When connectivity returns:

  1. Push — await engine.syncAll() (flush write queue)
  2. Pull — await pullCoordinator.runAll() (or per-feature)

Foreground adapters (FlutterSyncCoordinator, FlutterPullCoordinator) each listen for connectivity; coordinate order in your app when you run both manually.

Background Workmanager ​

One callback can run both:

dart
await runBackgroundSync(createBackgroundSyncEngine);
await runBackgroundPull(createBackgroundPullCoordinator);

Each factory re-opens package DBs at the same paths and rebuilds Dio + registries. See Foreground & background.

Integration boundaries ​

PieceLayer (typical)
SyncTaskHandler / PullStepHandlerData
buildRegistry / buildPullRegistryApp composition / DI
SyncEngine / PullCoordinatorInfrastructure
Repositories, App DBData
Screens / state managementPresentation

The packages do not require Bloc, Riverpod, or Injectable. See Clean architecture for a feature-first folder layout.

Released under the MIT License.