Sembast DevTools
A powerful development tool for debugging and visualizing Sembast databases in real-time. Create a web server on your mobile device to view and manage your local database from any browser on the same network.
🚀 Features
- Real-time visualization of your Sembast database
- Web interface accessible from any browser
- Multiple store support - view all your stores in one place
- CRUD operations - view, add, edit, and delete records
- Auto-refresh - see changes in real-time
- Network accessible - access from your computer while developing on mobile
- Beautiful UI - clean and intuitive interface
📦 Installation
Add this to your pubspec.yaml:
dependencies:
sembast_devtools: ^0.8.0
🛠️ Usage
Basic Setup
import 'package:sembast_devtools/sembast_devtools.dart';
import 'package:sembast/sembast_io.dart';
void main() async {
// Your existing database setup
final db = await databaseFactoryIo.openDatabase('my_app.db');
// Start DevTools server
final devtools = SembastDebugServer();
await devtools.start(
db,
storeNames: {'users', 'products'}, // Optional: specify which stores to show
port: 8080, // Optional: default is 8080
);
// Your app continues normally...
runApp(MyApp());
}
Complete Example
import 'package:flutter/material.dart';
import 'package:sembast/sembast_io.dart';
import 'package:sembast_devtools/sembast_devtools.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Setup database
final db = await databaseFactoryIo.openDatabase('example.db');
// Add some sample data
final usersStore = intMapStoreFactory.store('users');
await usersStore.add(db, {'name': 'John', 'age': 30});
// Start DevTools
final devtools = SembastDebugServer();
await devtools.start(db, storeNames: {'users'});
runApp(MaterialApp(
home: Scaffold(
body: Center(
child: Text('DevTools running on http://localhost:8080'),
),
),
));
}
🌐 Accessing the Web Interface
On the same device:
http://localhost:3338
From your computer (same network):
http://[YOUR_PHONE_IP]:3338
To find your phone's IP address:
- Android: Settings > About Phone > Status > IP Address
- iOS: Settings > Wi-Fi > (your network) > IP Address
🎛️ API Endpoints
The server provides a REST API for programmatic access:
GET /- Web interfaceGET /api/stores- List all storesGET /api/stores/{storeName}- Get all records from a storePOST /api/stores/{storeName}- Add a new recordPUT /api/stores/{storeName}/{key}- Update a recordDELETE /api/stores/{storeName}/{key}- Delete a record
⚙️ Configuration Options
await devtools.start(
database,
storeNames: {'store1', 'store2'}, // Only show specific stores
port: 3338, // Custom port
);
🔒 Security Notice
⚠️ Important: Only use this in development!
This tool is designed for development and debugging purposes only. Do not use in production as it:
- Exposes your database over the network
- Has no authentication
- Should only be used in trusted networks
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
This project is licensed under the MIT License.
🐛 Issues
Found a bug or have a feature request? Please open an issue on GitHub.