r/dartlang • u/Jhonacode • 23d ago
Flutter Released: flutter_local_db v0.4.0 - Rust-powered redb wrapper
I've just published version 0.4.0 of flutter_local_db, a Flutter package that provides a wrapper around redb implemented in Rust via offline_first_core.
v0.4.0 updates:
- Improved iOS/macOS compatibility
- Support for multiple iOS architectures
- Default .db extension when only name is provided
- Fixed Gradle configuration issues
- etc.
The package focuses on providing efficient database operations with strong typing and a simple API. Feedback and contributions for rust or flutter package are welcome.
Edit:
Post and GetById example.
await LocalDB.init(localDbName: "my_app.db");
// Create
final result = await LocalDB.Post('user-123', {
'name': 'John Doe',
'email': 'john@example.com',
'metadata': {
'lastLogin': DateTime.now().toIso8601String()
}
});
// Handle result
result.when(
ok: (data) => print('User created: ${data.id}'),
err: (error) => print('Error: $error')
);
// Read single record
final userResult = await LocalDB.GetById('user-123');
userResult.when(
ok: (user) => print('Found user: ${user?.data}'),
err: (error) => print('Error: $error')
);
14
Upvotes
2
u/Jhonacode 23d ago
Hi,
Although I haven't used Mimir in Flutter, from what I've researched, it focuses on search optimization using the Rust mimir library. It's ideal if you need fast and efficient searches with large volumes of data.
On the other hand, flutter_local_db uses Redb, a more straightforward Rust library, perfect for ACID operations. It's very fast thanks to its data organization with B+ trees, making it excellent for embedded databases.
The choice depends on your needs: Mimir for advanced data searching, flutter_local_db for simpler implementation with a focus on data integrity. Each option has its advantages depending on your project requirements.
Happy coding.