db_lens 🔍
A Flutter debug tool for inspecting SQLite and SharedPreferences directly on device — no adb, no external tools, no laptop needed.
Designed for QA and developers. Works out of the box. Hidden in release builds (
kReleaseMode).
Preview
| SQLite Browser | Pagination | SharedPreferences |
|---|---|---|
![]() |
![]() |
![]() |
Installation
dev_dependencies:
db_lens: ^0.0.5
Quick Start
import 'package:db_lens/db_lens.dart';
// SQLite
final db = await openDatabase('my_app.db');
DbLens.register('Main DB', db);
// SharedPreferences
final prefs = await SharedPreferences.getInstance();
DbLens.registerSharedPreferences('App Prefs', prefs);
// Open the inspector
DbLens.open(context);
DbLensButton
Drop it anywhere — app bar, drawer, debug menu, settings page. Automatically hidden in release builds.
// Default
DbLensButton()
// Custom label, icon, and style
DbLensButton(
label: 'Inspect Data',
icon: Icons.bug_report,
style: ElevatedButton.styleFrom(backgroundColor: Colors.teal),
)
Dynamic Theme
Align panel accent with your app's primary color via fromMaterialTheme(), or pass custom colors.
DbLens.open(
context,
theme: DbLensThemeData.fromMaterialTheme(Theme.of(context)),
);
// Or custom tokens
DbLens.open(
context,
theme: const DbLensThemeData(accent: Colors.teal),
);
Multiple Sources
DbLens.register('Main DB', mainDb);
DbLens.register('Cache DB', cacheDb);
DbLens.registerSharedPreferences('App Prefs', prefs);
Switch between sources inside the panel. Search and filter source and collection lists in real time.
Features
| 🗄️ | SQLite table browser with pagination |
| 🔑 | SharedPreferences inspector (key, type, value) |
| 🔎 | Search rows across all columns; searchable source & collection selectors |
| 📄 | Pagination (configurable via DbLensConfig.pageSize, default 10) |
| 🛠️ | Raw SQL query (SQLite); auto-select table on simple SELECT |
| 🎨 | Table / JSON view toggle — current page as pretty-printed JSON array |
| 📋 | Tap row → JSON bottom sheet; long-press → copy or edit cell |
| ✏️ | Edit cell values (SQLite UPDATE / SharedPreferences set*) |
| 📤 | Copy all rows as JSON |
| 🎨 | DbLensThemeData — customizable panel colors |
| 🔄 | Refresh on demand |
| 💾 | Multiple source support |
| 🔒 | No-op in release builds |
Configuration
DbLens.open(
context,
config: const DbLensConfig(
pageSize: 20,
enablePrefetch: true,
),
);
Example App
Run the included example to try every feature (SQLite + SharedPreferences, themed open, edit, JSON view):
cd example
flutter run
License
See LICENSE.
Libraries
- core/enums/source_type
- core/models/db_lens_config
- core/utils/parse_utils
- core/utils/sql_utils
- data/datasources/lens_datasource
- data/datasources/sqlite/sql_queryable_data_source
- data/datasources/sqlite/sqlite_data_source
- data/registry/db_lens_registry
- data/repositories/lens_repository_impl
- db_lens
- db_lens_facade
- domain/entities/collection_entity
- domain/entities/row_entity
- domain/entities/source_entity
- domain/repositories/lens_repository
- domain/usecases/execute_statement_use_case
- domain/usecases/get_all_rows_use_case
- domain/usecases/get_collections_use_case
- domain/usecases/get_columns_use_case
- domain/usecases/get_row_count_use_case
- domain/usecases/get_rows_use_case
- domain/usecases/get_sources_use_case
- domain/usecases/run_raw_query_count_use_case
- domain/usecases/run_raw_query_paged_use_case
- domain/usecases/update_cell_use_case
- presentation/controllers/db_lens_controller
- presentation/pages/db_lens_panel
- presentation/state/db_lens_pagination
- presentation/state/db_lens_panel_models
- presentation/theme/db_lens_theme
- presentation/theme/db_lens_theme_data
- presentation/utils/json_view_utils
- presentation/utils/row_utils
- presentation/widgets/db_lens_highlighted_text
- presentation/widgets/db_lens_panel_widgets
- presentation/widgets/db_lens_row_json_sheet


