Aus öffentlichen Paketdaten erstellte Orientierung.
dbx ist eine leichte, schnelle und einfache NoSQL-Datenbanklösung für Flutter-Anwendungen. Mit Fokus auf Einfachheit entwickelt, bietet sie eine benutzerfreundliche Schnittstelle für die dauerhafte Datenspeicherung über mehrere Plattformen hinweg. Ideal für Apps, die zuverlässige lokale Datenverarbeitung ohne die Komplexität traditioneller Datenbanken benötigen, unterstützt dbx Android, iOS, macOS, Windows und Linux. Seine minimale Einrichtung und effiziente Leistung machen es für kleine bis mittlere Datenanforderungen geeignet.
Anwendungsfälle
Speichern von Benutzereinstellungen
App-Daten zwischenspeichern
Offline-Benutzerinhalte speichern
Lokalen Zustand verwalten
Formulardaten beibehalten
Hauptmerkmale
Einfache API
Plattformübergreifende Unterstützung
Leichtbauweise
Schnelle Lese- und Schreibvorgänge
Automatische Datenpersistenz
Geeignet für
Anfänger-Flutter-Entwickler
Apps, die lokalen Speicher erfordern
Projekte mit geringen Datenbankanforderungen
Prototyping und MVP-Entwicklung
Kleinskalige Datenverwaltung
Hinweise
Nicht geeignet für große Datensätze
Eingeschränkte Abfragefunktionen
Keine integrierte Synchronisierung
Am besten für den Einsatz auf einem Gerät geeignet
Keine erweiterten Indizierungsfunktionen
Original-README
Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.
DBX
dbx is a Dart package designed for secure and efficient local storage using Protocol Buffers instead of JSON.
A Key-Value Database with Easy API that supports wide range of Data Types.
Features
Protocol Buffers: Utilizes Protocol Buffers (protobuf) for data serialization, offering significant performance improvements over JSON.
Secure Storage: Data is securely stored using flutter_secure_storage and encrypted with the encrypt library, with customizable encryption options.
Comprehensive Data Support: Supports all data types, including their list variants and JSON objects.
What we mean
Supported data types are int, double, bool, String, Uint8List, List<int>, List<double>, List<bool>, List<String>, List<Uint8List>, and Map<String, dynamic> (JSON).
Uint8List for bytes, JSON for custom objects
Efficient and Compact: Protobuf is more efficient and compact compared to JSON, with built-in data compression (gzip), reducing latency and improving app performance.
Customizable Encryption: Configure AES modes, key lengths, and IV lengths for enhanced security.
Generic Operations: Type-agnostic get/set methods for dynamic data handling.
Batch Operations: Efficient bulk read/write operations for multiple keys.
Indexing & Search: Fast key lookups, sorted keys, prefix-based searches, and existence checks.
Synchronization: Export/import functionality for data backup and cross-device sync.
Schema Versioning: Automatic migrations for schema evolution.
Utilities: Key count, file size monitoring, and bulk data removal.
Familiar Api: Same API as of SharedPreference.
Won't miss SharedPreference. No headache, easy adaption.🚀
Created With Simplicity in mind
No Object Creation, no overhead of state management solution
No Object Passing
All method are static, just call and use.
Benefits of Using Protocol Buffers Over JSON
Performance: Protobuf is significantly faster than JSON for serialization and deserialization.
Compactness: Protobuf messages are smaller in size, which reduces storage space and improves transmission speed.
Efficiency: Protobuf is more efficient in terms of CPU and memory usage.
Advantages Over Shared Preferences
Data Integrity: Protobuf ensures data integrity and consistency, which is crucial for complex data structures.
Security: Data is encrypted and securely stored, unlike shared preferences which can be more vulnerable to security breaches.
Scalability: Protobuf's efficient serialization makes it suitable for larger datasets and more complex data structures.
// Check existencebool exists = DBX.containsKey('someKey');
// Get all keysList<String> allKeys = DBX.getAllKeys();
// Get sorted keysList<String> sortedKeys = DBX.getAllKeysSorted();
// Prefix searchList<String> appKeys = DBX.getKeysStartingWith('app');
Synchronization & Backup
DBX provides export/import functionality for data backup and synchronization across devices.
Basic Backup and Restore
// Create a backupUint8List backupData = await DBX.exportData();
// Save to local file or external storageawaitFile('/path/to/backup.dbx').writeAsBytes(backupData);
// Restore from backupUint8List restoredData = awaitFile('/path/to/backup.dbx').readAsBytes();
await DBX.importData(restoredData);
Cross-Device Synchronization
For syncing data between multiple devices:
Initialize with shared key seed (same on all devices):
Conflict Resolution: Last imported data wins (no built-in merging)
Use export/import for periodic backups or when switching devices. For real-time sync, combine with cloud storage webhooks.
Note: For cross-device sync, ensure all devices use the same keySeed during initialization to maintain data compatibility.
Utilities
// Get statisticsint keyCount = DBX.keyCount;
int fileSize = await DBX.fileSize;
// Remove all data
DBX.removeAll();
// Clear and delete file
DBX.clearAll();