local_db_explorer 1.0.0+3
local_db_explorer: ^1.0.0+3 copied to clipboard
A lightweight in-app database viewer/inspector for debugging local storage (Sqflite, Hive, SharedPreferences).
DB Explorer Examples #
This directory contains comprehensive examples demonstrating the local_db_explorer
package with different database types and use cases.
Available Examples #
1. π± Basic Sqflite Example #
Location: example/
Database: SQLite (Sqflite)
Complexity: Basic
Demonstrates the core functionality with a simple SQLite database:
- Users and Posts tables with relationships
- Basic CRUD operations
- Single database adapter
Perfect for: Getting started with DB Explorer
2. π¦ Hive Example #
Location: examples/hive_example/
Database: Hive
Complexity: Intermediate
Shows how to inspect Hive boxes with typed objects:
- User and Post objects with Hive adapters
- Settings box with key-value pairs
- Mock HiveAdapter implementation
Perfect for: Hive users, NoSQL storage patterns
3. βοΈ SharedPreferences Example #
Location: examples/shared_preferences_example/
Database: SharedPreferences
Complexity: Basic
Demonstrates preference inspection and management:
- All SharedPreferences data types
- App settings and user preferences
- Mock SharedPreferencesAdapter implementation
Perfect for: App configuration debugging
4. ποΈ Multi-Database Example #
Location: examples/multi_database_example/
Database: SQLite + Hive + SharedPreferences
Complexity: Advanced
Showcases the full power of the adapter architecture:
- Three databases running simultaneously
- Tabbed interface in DB Explorer
- Cross-database operations
- Real-world data models
Perfect for: Complex apps, architecture demonstration
Quick Start #
Choose the example that matches your use case:
# Basic SQLite example
cd example
flutter run
# Hive example
cd examples/hive_example
flutter pub get
flutter run
# SharedPreferences example
cd examples/shared_preferences_example
flutter pub get
flutter run
# Multi-database example
cd examples/multi_database_example
flutter pub get
flutter run
Example Comparison #
Example | Databases | Adapters | Use Case |
---|---|---|---|
Basic | SQLite | 1 (Real) | Learning, simple apps |
Hive | Hive | 1 (Mock) | NoSQL, typed objects |
SharedPreferences | Preferences | 1 (Mock) | App settings |
Multi-Database | All 3 | 3 (1 Real, 2 Mock) | Complex apps, demos |
Development Status #
- β SqfliteAdapter: Fully implemented and functional
- π§ HiveAdapter: Stub implementation (examples use mock)
- π§ SharedPreferencesAdapter: Stub implementation (examples use mock)
The mock implementations in the examples demonstrate exactly how the real adapters will work once implemented.
Contributing #
Want to help complete the adapter implementations? Check out:
lib/src/adapters/hive_adapter.dart
- Needs full Hive integrationlib/src/adapters/shared_preferences_adapter.dart
- Needs full SharedPreferences integration
The examples provide perfect test cases and expected behavior for these implementations.
Example Features #
All examples include:
- π DB Explorer Integration - Open inspector with a button
- π Sample Data - Pre-populated realistic data
- β Add Data - Dynamic data insertion
- π Reset Data - Restore sample data
- π± Material Design - Beautiful, responsive UI
- π Debug Mode Only - Secure by default
Architecture Insights #
The examples demonstrate key architectural patterns:
Single Responsibility #
Each adapter handles one database type with a consistent interface.
Adapter Pattern #
Different storage mechanisms unified under a common API.
Overlay UI #
Non-intrusive inspection that doesn't affect app navigation.
Type Safety #
Each adapter handles its own data types and serialization.
Debug Security #
All functionality disabled in release builds.
Next Steps #
- Try the examples to understand DB Explorer capabilities
- Integrate into your app using the pattern that fits your needs
- Contribute by helping implement the remaining adapters
- Extend by creating adapters for other database types (Isar, ObjectBox, etc.)
Happy debugging! ππ