Realm Flutter 1.3 released! Dart 3 here we come…

Kasper Nielsen
Realm Blog
3 min readJun 22, 2023

--

Today we are happy to announce the release of version 1.3 of the Realm Flutter and Dart SDK.

This marks the first release that will only work with Dart 3 and later. It has been great to see how fast the community has moved to 3.0, and today Realm follows along. We are excited about the future of Flutter and Dart and we are looking forward to embracing the upcoming support for static meta-programming.

Since the initial release of Realm Flutter v1 back in February we have:

  • Enabled full-text search (FTS).
  • Added support for IEEE 754–2008 128-bit decimals (Decimal128).
  • Added support for raw binary (Uint8List).
  • We have enabled multiple processes to work on encrypted Realms simultaneously.
  • We have fixed the concurrent use of sync and async transactions.
  • Fixed the query parser when querying RealmValues and added an index on that type.
  • Implemented memory optimizations for our query engine and parser.
  • Improved query performance for counting queries, indexed timestamp queries, indexed RealmValue queries, and equality queries on non-indexed RealmValues.
  • Improved the performance when rolling back write transactions.
  • Refactored logging - fixing multi-isolate logging in the process.

and much more.

You can check the CHANGELOG for the full details, but let's briefly visit some of the user-visible highlights:

Full-Text Search

Full-text search (FTS) was added to Realm Flutter in v1.2.0. Here is how to use it:

import 'package:realm_dart/realm.dart';

part 'fts_ex.g.dart';

@RealmModel()
class _Book {
@Indexed(RealmIndexType.fullText)
late String title;
}

void main(List<String> arguments) {
final realm = Realm(Configuration.inMemory([Book.schema]));

realm.write(() => realm.addAll([
Book('Animal Farm'),
Book('The Lord of the Rings'),
Book('Lord of the Flies'),
Book('The Wheel of Time'),
Book('The Silmarillion'),
]));

realm.query<Book>('title TEXT \$0', ['the']).forEach((e) => print(e.title));
print('---');
realm.query<Book>('title TEXT \$0', ['of']).forEach((e) => print(e.title));
print('---');
realm.query<Book>('title TEXT \$0', ['farm']).forEach((e) => print(e.title));

Realm.shutdown();
}

outputs:

The Lord of the Rings
Lord of the Flies
The Wheel of Time
The Silmarillion
---
The Lord of the Rings
Lord of the Flies
The Wheel of Time
---
Animal Farm

Decimal128

Customers have been requesting support for IEEE 754–2008 128-bit decimal for a while, and support was finally released with v1.1.0.

This allows you to store, fetch, query and do basic arithmetics with Decimal128.

Here is a quick example:

import 'package:realm_dart/realm.dart';

part 'dec128_ex.g.dart';

@RealmModel()
class _Stuff {
late Decimal128 value;
}

void main(List<String> arguments) {
// The maximum value of long double in 64 bit precision is 1.8 x 10^308,
// so let us use a bigger number
final big = Decimal128.parse('1e310');
final two = Decimal128.fromInt(2);

print(1e310); // double can't ..
print(big); // .. but Decimal128 can

final realm = Realm(Configuration.inMemory([Stuff.schema]));
realm.write(() => realm.add(Stuff(big)));
print(realm.all<Stuff>().first.value);
print(big + big);
print(big - big);
print(big * two);
print(big / two);
print(big / Decimal128.zero);

Realm.shutdown();
}

outputs:

Infinity
+1E+310
+1E+310
+2E+310
+0E+310
+2E+310
+5E+309
+Inf

Uint8List (binary)

Another datatype previously missing from the Flutter and Dart SDKs as raw binary. With version 1.3 you can now store Uint8Lists in realms as well:

import 'dart:typed_data';

import 'package:realm_dart/realm.dart';

part 'bin_ex.g.dart';

@RealmModel()
class _Stuff {
late Uint8List bytes;
}

void main(List<String> arguments) {
final realm = Realm(Configuration.inMemory([Stuff.schema]));
final stuff = Stuff(Uint8List.fromList([1, 2, 3]));
realm.write(() => realm.add(stuff));
realm.all<Stuff>().forEach((e) => print(e.bytes));
Realm.shutdown();
}

outputs:

[1, 2, 3]

For more information visit the Realm Flutter documentation. We hope you like this Realm Flutter release. Stay tuned for more.

If you have any questions or need assistance, please don’t hesitate to reach out to us on GitHub or Community Forum.

--

--