Uma solução de armazenamento de dados criada com simplicidade em mente. É uma solução de banco de dados simples, leve e rápida para aplicativos Flutter.
Orientação gerada a partir de informações públicas. Apenas para referência.
dbx é uma solução leve, rápida e simples de banco de dados NoSQL projetada para aplicativos Flutter. Construída com simplicidade em mente, oferece uma interface fácil de usar para armazenamento persistente de dados em múltiplas plataformas. Ideal para aplicativos que precisam de um manuseio confiável de dados locais sem a complexidade dos bancos de dados tradicionais, o dbx suporta Android, iOS, macOS, Windows e Linux. Sua configuração mínima e desempenho eficiente tornam-no adequado para necessidades de dados de pequeno a médio porte.
Casos de uso
Armazenando preferências do usuário
Armazenar dados do aplicativo em cache
Salvando conteúdo do usuário offline
Gerenciando estado local
Persistência de dados do formulário
Principais recursos
API simples
Suporte multiplataforma
Design leve
Operações rápidas de leitura e escrita
Persistência automática de dados
Indicado para
Desenvolvedores iniciantes do Flutter
Aplicativos que exigem armazenamento local
Projetos com necessidades mínimas de banco de dados
Prototipagem e desenvolvimento de MVP
Gerenciamento de dados em pequena escala
Considerações
Não adequado para grandes conjuntos de dados
Capacidades limitadas de consulta
Sem sincronização embutida
Melhor para uso em dispositivo único
Sem recursos avançados de indexação
README original
Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.
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();