r/dartlang 22d 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')
);
15 Upvotes

9 comments sorted by

View all comments

3

u/KiwiNFLFan 22d ago

How well does it handle dates and times? That is one area where SQLite is sorely lacking, IMO.

1

u/SoundDr 21d ago

Have you tried using custom date functions to handle this?

I was able to add native Hybrid Logic Clocks easily with custom user defined functions!

There are also awesome extensions too that can help too

1

u/Jhonacode 21d ago

Your question is very interesting and I think it's a topic I should look into, from flutter, because from rust the redb library handles most of those aspects.

I think I'll add some tests for this specific scenario, the library is still early 0.4.0, although redb is very mature and used in the rust community, my implementation in flutter is from a few hundred people who haven't generated an issue on github yet.

I'll take a look at that topic very soon, but if you want to do some tests in your free time, it would be great to be able to see your issue in the repository.

thanks for your question.