flutter_db_inspector_sembast
Sembast adapter for Flutter DB Inspector.
Pure Dart: works with sembast, sembast_web and sembast_sqflite
databases.
Install
dependencies:
flutter_db_inspector: ^1.0.0
flutter_db_inspector_sembast: ^1.0.0
Register
import 'package:flutter_db_inspector/flutter_db_inspector.dart';
import 'package:flutter_db_inspector_sembast/flutter_db_inspector_sembast.dart';
final db = await databaseFactoryIo.openDatabase(path);
DbInspector.initialize(enabled: kDebugMode);
DbInspector.registerDatabase(
name: 'app',
// Non-empty stores are discovered; list stores that may be empty.
adapter: SembastAdapter(db, stores: ['drafts']),
);
Pass discoverStores: false to show exactly the stores you list.
How data is shown
- Every store is a collection; each record is a row addressed by its key in
the
_keycolumn (Sembast'sField.key).intandStringkeys are both supported. - Map records show one column per field. Sembast is schemaless, so columns are inferred from the stored records.
- Records that are not maps (
StoreRef<String, String>, counters, lists, ...) are shown in a single_valuecolumn (Sembast'sField.value) and are edited through it. - Sembast
TimestampandBlobvalues are shown as date-times and bytes, and date-times/bytes entered in the inspector are stored asTimestamp/Blob. - Inserting without a
_keygenerates one of the store's key type (Stringwhen existing keys are strings, otherwise an auto-incrementedint).
Filtering, sorting, paging and counting run inside Sembast (Finder,
Filter, SortOrder). Free-text search, and queries on _value, are
evaluated by the generic engine.
Limitations
- Sembast does not record empty stores, so they appear only when listed in
stores. - Only top-level fields are columns; nested maps are shown (and edited) as JSON.
- A map record field literally named
_keyor_valueis shadowed by the inspector's key/value columns. - Updates replace the edited fields; the record key cannot be changed.
Libraries
- flutter_db_inspector_sembast
- Sembast adapter for Flutter DB Inspector.