sembast_devtools 0.8.1
sembast_devtools: ^0.8.1 copied to clipboard
DevTools for Sembast database - Real-time web interface to visualize and debug your local database during development.
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
âšī¸ Port Forwarding Notice:
When running on an Android emulator, Sembast DevTools will automatically set up ADB port forwarding for you (if adb is available in your system PATH).
If you are not using an emulator or if adb is not available, you may need to set up port forwarding manually to access the DevTools from your computer:
- Check existing forwards:
adb forward --list - If port
3338is not listed, add it:adb [YOUR_EMULATOR_NAME] forward tcp:3338 tcp:3338 - Now you can access DevTools from your computer at:
http://localhost:3338
Make sure adb is installed and available in your terminal.
For more details, see Android documentation.
đ ī¸ 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: 3338, // Optional: default is 3338
);
// 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.