dart_data_rest
REST backend adapter for dart_data — the SwiftData for Flutter.
Connect your offline-first local database to any REST API. Handles push, pull, pagination, and authentication out of the box.
Installation
dependencies:
dart_data: ^0.1.0
dart_data_rest: ^0.1.0
Usage
import 'package:dart_data/dart_data.dart';
import 'package:dart_data_rest/dart_data_rest.dart';
final adapter = RestAdapter();
await adapter.initialize(BackendConfig(
url: 'https://api.example.com',
headers: {'Authorization': 'Bearer token'},
));
final syncEngine = SyncEngine(
adapter: adapter,
queue: OperationQueue(storage: sqliteStorage),
statusNotifier: SyncStatusNotifier(),
modelTypes: ['Todo'],
);
await syncEngine.sync();
How It Works
The REST adapter maps dart_data sync operations to standard HTTP verbs:
| Operation | HTTP Method | Endpoint |
|---|---|---|
| Create | POST |
/todos |
| Update | PATCH |
/todos/:id |
| Delete | DELETE |
/todos/:id |
| Pull | GET |
/todos?since=<timestamp> |
Endpoint mapping and response parsing are configurable.
Learn More
See the dart_data documentation for full framework docs.
License
BSD 3-Clause. See LICENSE.
Libraries
- dart_data_rest
- REST backend adapter for dart_data.