sqflite_db_inspector 0.1.5
sqflite_db_inspector: ^0.1.5 copied to clipboard
Flutter DevTools extension and VM service hook to browse sqflite databases in any Flutter app (tables, schema, row preview, live refresh).
sqflite_db_inspector #
Flutter DevTools extension plus a VM service hook to inspect sqflite in any Flutter app: browse tables, column metadata, row preview, filters, and CRUD (debug/profile only).
Required: register the VM hook in your app #
The DevTools UI does nothing until your running app calls registerSqliteInspector. That registers the VM service extension DevTools talks to.
You should:
- Add
sqflite_db_inspectortodependencies(see below). - After
WidgetsFlutterBinding.ensureInitialized(), callregisterSqliteInspectoronce per process (wrapped in!kReleaseModeis recommended). Pass a callback that returns theFuture<Database>your app actually uses for sqflite—not a second connection unless intentional. - If the project has multiple entrypoints (e.g.
main_development.dart,main_staging.dart) that do not share the same bootstrap code path, register in each path that can run under DevTools. Otherwise that flavor will show errors like the extension not being registered or no data.
Release builds: registerSqliteInspector returns immediately in release (kReleaseMode); no DevTools traffic in production.
See also the dartdoc on registerSqliteInspector in the package API (IDE hover).
On pub.dev, the Example tab shows the example/ app (same code as in the published tarball).
Add to your app #
dependencies:
sqflite_db_inspector: ^0.1.5
Registration snippet #
After WidgetsFlutterBinding.ensureInitialized():
import 'package:flutter/foundation.dart';
import 'package:sqflite_db_inspector/sqflite_db_inspector.dart';
if (!kReleaseMode) {
registerSqliteInspector(() => yourOpenDatabase());
}
Replace yourOpenDatabase with your real opener (e.g. () => LocalDatabase.instance.database). It must return the same Future<Database> the rest of the app uses.
DevTools #
Enable the extension (optional devtools_options.yaml):
extensions:
- sqflite_db_inspector: true
License #
BSD-3-Clause — LICENSE.