Releases: realm/realm-dart
2.3.0
2.3.0 (2024-05-23)
Enhancements
- Added support for creating and storing a RealmObject using the
Realm.dynamic
API:realm.dynamic.create("Person", primaryKey: 123)
. (PR #1669) - Added support for setting properties on a RealmObject using the dynamic API:
obj.dynamic.set("name", "Peter")
. (PR #1669) - Listening for
.changes
on a dynamic object (obtained via therealm.dynamic
API) no longer throws. (Issue #1668) - Nested collections have full support for automatic client reset. (Core 14.7.0)
Fixed
-
Private fields did not work with default values. (Issue #1663)
-
Invoke scheduler callback on Zone.current. (Issue #1676)
-
Having links in a nested collections would leave the file inconsistent if the top object is removed. (Core 14.7.0)
-
Accessing App.currentUser from within a notification produced by App.switchUser() (which includes notifications for a newly logged in user) would deadlock. (Core 14.7.0)
-
Inserting the same typed link to the same key in a dictionary more than once would incorrectly create multiple backlinks to the object. This did not appear to cause any crashes later, but would have affecting explicit backlink count queries (eg:
...@links.@count
) and possibly notifications. (Core 14.7.0)
Compatibility
- Realm Studio: 15.0.0 or later.
Internal
- Using Core 14.7.0.
2.2.1
2.2.0
2.2.0 (2024-05-01)
Enhancements
- Allow configuration of generator per model class. Currently support specifying the constructor style to use.
will generate a constructor like:
const config = GeneratorConfig(ctorStyle: CtorStyle.allNamed); const realmModel = RealmModel.using(baseType: ObjectType.realmObject, generatorConfig: config); @realmModel class _Person { late String name; int age = 42; }
(Issue #292)Person({ required String name, int age = 42, }) { ... }
- Add privacy manifest to apple binaries. (Issue #1551)
Fixed
- Avoid: Attempt to execute code removed by Dart AOT compiler (TFA). (Issue #1647)
- Fixed nullability annotations for the experimental API
App.baseUrl
andApp.updateBaseUrl
. The former is guaranteed not to benull
, while the latter will now accept anull
argument, in which case the base url will be restored to its default value. (Issue #1523) App.users
included logged out users only if they were logged out while the App instance existed. It now always includes all logged out users. (Core 14.6.0)- Fixed several issues around encrypted file portability (copying a "bundled" encrypted Realm from one device to another): (Core 14.6.0)
- Fixed
Assertion failed: new_size % (1ULL << m_page_shift) == 0
when opening an encrypted Realm less than 64Mb that was generated on a platform with a different page size than the current platform. - Fixed a
DecryptionFailed
exception thrown when opening a small (<4k of data) Realm generated on a device with a page size of 4k if it was bundled and opened on a device with a larger page size. - Fixed an issue during a subsequent open of an encrypted Realm for some rare allocation patterns when the top ref was within ~50 bytes of the end of a page. This could manifest as a DecryptionFailed exception or as an assertion:
encrypted_file_mapping.hpp:183: Assertion failed: local_ndx < m_page_state.size()
.
- Fixed
- Schema initialization could hit an assertion failure if the sync client applied a downloaded changeset while the Realm file was in the process of being opened. (Core 14.6.0)
- Improve perfomance of "chained OR equality" queries for UUID/ObjectId types and RQL parsed "IN" queries on string/int/uuid/objectid types. (Core 14.6.0)
- Fixed a bug when running a IN query (or a query of the pattern
x == 1 OR x == 2 OR x == 3
) when evaluating on a string property with an empty string in the search condition. Matches with an empty string would have been evaluated as if searching for a null string instead. (Core 14.6.2)
Compatibility
- Realm Studio: 15.0.0 or later.
Internal
- Using Core 14.6.2.
- Flutter: ^3.19.0
- Dart: ^3.3.0
2.1.0
2.1.0 (2024-04-17)
Enhancements
- Improve file compaction performance on platforms with page sizes greater than 4k (for example arm64 Apple platforms) for files less than 256 pages in size (Core 14.4.0).
- Add better hint to error message, if opening native library fails. (Issue #1595)
- Added support for specifying schema version on
Configuration.flexibleSync
. This allows you to take advantage of an upcoming server-side feature that will allow schema migrations for synchronized Realms. (Issue #1599) - The default base url in
AppConfiguration
has been updated to point toservices.cloud.mongodb.com
. See https://www.mongodb.com/docs/atlas/app-services/domain-migration/ for more information. (Issue #1549) - Don't ignore private fields on realm models. (Issue #1367)
- Improve performance of
RealmValue.operator==
when containing binary data. (PR #1628)
Fixed
- Using valid const, but non-literal expressions, such as negation of numbers, as an initializer would fail. (Issue #1606)
- Backlinks mistakenly included in EJson serialization. (Issue #1616)
- Fix an assertion failure "m_lock_info && m_lock_info->m_file.get_path() == m_filename" that appears to be related to opening a Realm while the file is in the process of being closed on another thread. (Core 14.5.0)
- Fixed diverging history due to a bug in the replication code when setting default null values (embedded objects included). (Core 14.5.0)
- Null pointer exception may be triggered when logging out and async commits callbacks not executed. (Core 14.5.0)
- Comparing RealmValue containing a collection to itself would return false. Semantics changed to ensure reference equality always imply equality. (Issue [#1632])
- Clearing a nested collection could end with a crash. (Core 14.5.1)
- Removing nested collections in RealmValue for synced realms throws. (Core 14.5.1)
- Fixed crash when integrating removal of already removed dictionary key. (Core 14.5.2)
Compatibility
- Realm Studio: 15.0.0 or later.
Internal
- Using Core 14.5.2.
2.0.0-beta.2
2.0.0-beta.2 (2024-03-20)
Breaking Changes
-
RealmValue.type
is now an enum of typeRealmValueType
rather thanType
. If you need the runtime type of the value wrapped inRealmValue
, useRealmValue.value.runtimeType
. (Issue #1505) -
Renamed
RealmValue.uint8List
constructor toRealmValue.binary
. (PR #1469) -
Removed the following deprecated classes and members:
AppConfiguration.localAppName
- was unused and had no effectAppConfiguration.localAppVersion
- was unused and had no effectClientResetError.isFatal
- it was alwaystrue
ClientResetError.sessionErrorCode
SyncError.codeValue
- can be accessed throughSyncError.code.code
SyncError.category
- categories were deprecated in1.6.0
SyncError.detailedMessage
- was always emptySyncError
constructor andSyncError.create
factory - sync errors are created internally by the SDK and are not supposed to be constructed by usersSyncClientError
,SyncConnectionError
,SyncSessionError
,SyncResolveError
,SyncWebSocketError
,GeneralSyncError
- consolidated intoSyncError
as part of the error simplification in1.6.0
RealmProperty.indexed
- replaced byRealmProperty.indexType
SyncErrorCategory
,SyncClientErrorCode
,SyncConnectionErrorCode
,SyncSessionErrorCode
,SyncResolveErrorCode
,SyncWebsocketErrorCode
,GeneralSyncErrorCode
- consolidated intoSyncErrorCode
as part of the error simplification in1.6.0
User.provider
- the provider is associated with each identity, so the value was incorrect for users who had more than one identity
-
The generated parts are now named
.realm.dart
instead of.g.dart
. This is because the builder is now aPartBuilder
, instead of aSharedPartBuilder
. To migrate to this version you need to update all the part declarations to match, ie.part 'x.g.dart
becomespart x.realm.dart
and rerun the generator.This makes it easier to combine builders. Here is an example of combining with
dart_mappable
:import 'package:dart_mappable/dart_mappable.dart'; import 'package:realm_dart/realm.dart'; part 'part_builder.realm.dart'; part 'part_builder.mapper.dart'; @MappableClass() @RealmModel() class $Stuff with $StuffMappable { @MappableField() late int id; @override String toString() => 'Stuff{id: $id}'; } final realm = Realm(Configuration.local([Stuff.schema])); void main(List<String> arguments) { final s = realm.write(() => realm.add(Stuff(1), update: true)); print(s.toJson()); // <-- realm object as json Realm.shutdown(); }
-
Removed
SchemaObject.properties
- instead,SchemaObject
is now an iterable collection ofProperty
. (Issue #1449) -
SyncProgress.transferredBytes
andSyncProgress.transferableBytes
have been consolidated intoSyncProgress.progressEstimate
. The values reported previously were incorrect and did not accurately represent bytes either. The new field better conveys the uncertainty around the progress being reported. With this release, we're reporting accurate estimates for upload progress, but estimating downloads is still unreliable. A future server and SDK release will add better estimations for download progress. (Issue #1562) -
Realm.logger
is no longer settable, and no longer implementsLogger
from packagelogging
. In particular you can no longer callRealm.logger.level =
. Instead you should callRealm.logger.setLogLevel(RealmLogLevel level, {RealmLogCategory? category})
that takes an optional category. If no category is exlicitly given, thenRealmLogCategory.realm
is assumed.Also, note that setting a level is no longer local to the current isolate, but shared accross all isolates. At the core level there is just one process wide logger.
Categories form a hierarchy and setting the log level of a parent category will override the level of its children. The hierarchy is exposed in a type safe manner with:
sealed class RealmLogCategory { /// All possible log categories. static final values = [ realm, realm.app, realm.sdk, realm.storage, realm.storage.notification, realm.storage.object, realm.storage.query, realm.storage.transaction, realm.sync, realm.sync.client, realm.sync.client.changeset, realm.sync.client.network, realm.sync.client.reset, realm.sync.client.session, realm.sync.server, ...
The
onRecord
stream now pumpsRealmLogRecord
s that include the category the message was logged to.If you want to hook up realm logging with conventional dart logging you can do:
Realm.logger.onRecord.forEach((r) => Logger(r.category.toString()).log(r.level.level, r.message));
If no isolate subscribes to
Realm.logger.onRecord
then the logs will by default be sent to stdout.
Enhancements
-
Realm objects can now be serialized as EJSON
import 'package:ejson/ejson.dart'; // ... class _Event { late DateTime timestamp; late String message; } // ... final ejson = toEJson(aRealmObject); final anUnmanagedRealmObject = fromEJson<Event>(ejson);
-
Added
isCollectionDeleted
toRealmListChanges
,RealmSetChanges
, andRealmMapChanges
which will betrue
if the parent object, containing the collection has been deleted. (Core 14.0.0) -
Added
isCleared
toRealmMapChanges
which will betrue
if the map has been cleared. (Core 14.0.0) -
Querying a specific entry in a collection (in particular 'first and 'last') is supported. (Core 14.0.0)
class _Owner { late List<_Dog> dogs; } realm.query<Owner>('dogs[1].age = 5'); // Query all owners whose second dog element is 5 years old realm.query<Owner>('dogs[FIRST].age = 5'); // Query all owners whose first dog is 5 years old realm.query<Owner>('dogs[LAST].age = 5'); // Query all owners whose last dog is 5 years old realm.query<Owner>('dogs[SIZE] = 10'); // Query all owners who have 10 dogs
-
Added support for storing lists and maps inside a
RealmValue
property. (Issue #1504)class _Container { late RealmValue anything; } realm.write(() { realm.add(Container(anything: RealmValue.from([1, 'foo', 3.14]))); }); final container = realm.all<Container>().first; final list = container.anything.asList(); // will throw if cast is invalid for (final item in containerValue) { switch (item.type) { case RealmValueType.int: print('Integer: ${item.value as int}'); break; case RealmValueType.string: print('String: ${item.value as String}'); break; case RealmValueType.double: print('Double: ${item.value as double}'); break; } } final subscription = list.changes.listen((event) { // The list changed });
-
Added
RealmValueType
enum that contains all the possible types that can be wrapped by aRealmValue
. (PR #1469) -
Added support for accessing
Set
andMap
types using the dynamic object API -obj.dynamic.getSet/getMap
. (PR #1533) -
Added
RealmObjectBase.objectSchema
that returns the schema for this object. In most cases, this would be the schema defined in the model, but in case the Realm is opened as dynamic (by providing an empty collection for schemaObjects in the config) or usingFlexibleSyncConfiguration
, it may change as the schema on disk changes. (Issue #1449) -
Added
Realm.schemaChanges
that returns a stream of schema changes that can be listened to. Only dynamic and synchronized Realms will emit schema changes. (Issue #1449) -
Improve performance of object notifiers with complex schemas and very simple changes to process by as much as 20% ([Core 14.2.0).
-
Improve performance with very large number of notifiers as much as 75% (Core 14.2.0).
-
Add support to synchronize collections embedded in Mixed properties and other collections (except sets) (Core v14.2.0-12-g95c6efce8).
-
Improve performance of change notifications on nested collections somewhat (Core v14.2.0-12-g95c6efce8).
-
Improve performance of aggregate operations on Dictionaries of objects, particularly when the dictionaries are empty (Core v14.2.0-12-g95c6efce8)
Fixed
- If you have more than 8388606 links pointing to one specific object, the program will crash. (Core 14.0.0)
- A Realm generated on a non-apple ARM 64 device and copied to another platform (and vice-versa) were non-portable due to a sorting order difference. This impacts strings or binaries that have their first difference at a non-ascii character. These items may not be found in a set, or in an indexed column if the strings had a long common prefix (> 200 characters). (Core 14.0.0)
- Ctor arguments appear in random order on generated classes, if the realm model contains many properties. (PR #1531)
- Fixed an issue where removing realm objects from a List with more than 1000 items could crash. (Core 14.2.0)
- Fix a spurious crash related to opening a Realm on background thread while the process was in the middle of exiting (Core v14.2.0-12-g95c6efce8)
Compatibility
- Realm Studio: 14.0.0 or later.
- Fileformat: Generates files with format v24. Reads and automatically upgrade from fileformat v10. If you want to upgrade from an earlier file format version you will have to use RealmCore v13.x.y or earlier.
Internal
- Using Core v14.2.0-12-g95c6ef...
2.0.0
2.0.0 (2024-03-20)
Breaking Changes
-
RealmValue.type
is now an enum of typeRealmValueType
rather thanType
. If you need the runtime type of the value wrapped inRealmValue
, useRealmValue.value.runtimeType
. (Issue #1505) -
Renamed
RealmValue.uint8List
constructor toRealmValue.binary
. (PR #1469) -
Removed the following deprecated classes and members:
AppConfiguration.localAppName
- was unused and had no effectAppConfiguration.localAppVersion
- was unused and had no effectClientResetError.isFatal
- it was alwaystrue
ClientResetError.sessionErrorCode
SyncError.codeValue
- can be accessed throughSyncError.code.code
SyncError.category
- categories were deprecated in1.6.0
SyncError.detailedMessage
- was always emptySyncError
constructor andSyncError.create
factory - sync errors are created internally by the SDK and are not supposed to be constructed by usersSyncClientError
,SyncConnectionError
,SyncSessionError
,SyncResolveError
,SyncWebSocketError
,GeneralSyncError
- consolidated intoSyncError
as part of the error simplification in1.6.0
RealmProperty.indexed
- replaced byRealmProperty.indexType
SyncErrorCategory
,SyncClientErrorCode
,SyncConnectionErrorCode
,SyncSessionErrorCode
,SyncResolveErrorCode
,SyncWebsocketErrorCode
,GeneralSyncErrorCode
- consolidated intoSyncErrorCode
as part of the error simplification in1.6.0
User.provider
- the provider is associated with each identity, so the value was incorrect for users who had more than one identity
-
The generated parts are now named
.realm.dart
instead of.g.dart
. This is because the builder is now aPartBuilder
, instead of aSharedPartBuilder
. To migrate to this version you need to update all the part declarations to match, ie.part 'x.g.dart
becomespart x.realm.dart
and rerun the generator.This makes it easier to combine builders. Here is an example of combining with
dart_mappable
:import 'package:dart_mappable/dart_mappable.dart'; import 'package:realm_dart/realm.dart'; part 'part_builder.realm.dart'; part 'part_builder.mapper.dart'; @MappableClass() @RealmModel() class $Stuff with $StuffMappable { @MappableField() late int id; @override String toString() => 'Stuff{id: $id}'; } final realm = Realm(Configuration.local([Stuff.schema])); void main(List<String> arguments) { final s = realm.write(() => realm.add(Stuff(1), update: true)); print(s.toJson()); // <-- realm object as json Realm.shutdown(); }
-
Removed
SchemaObject.properties
- instead,SchemaObject
is now an iterable collection ofProperty
. (Issue #1449) -
SyncProgress.transferredBytes
andSyncProgress.transferableBytes
have been consolidated intoSyncProgress.progressEstimate
. The values reported previously were incorrect and did not accurately represent bytes either. The new field better conveys the uncertainty around the progress being reported. With this release, we're reporting accurate estimates for upload progress, but estimating downloads is still unreliable. A future server and SDK release will add better estimations for download progress. (Issue #1562) -
Realm.logger
is no longer settable, and no longer implementsLogger
from packagelogging
. In particular you can no longer callRealm.logger.level =
. Instead you should callRealm.logger.setLogLevel(RealmLogLevel level, {RealmLogCategory? category})
that takes an optional category. If no category is exlicitly given, thenRealmLogCategory.realm
is assumed.Also, note that setting a level is no longer local to the current isolate, but shared accross all isolates. At the core level there is just one process wide logger.
Categories form a hierarchy and setting the log level of a parent category will override the level of its children. The hierarchy is exposed in a type safe manner with:
sealed class RealmLogCategory { /// All possible log categories. static final values = [ realm, realm.app, realm.sdk, realm.storage, realm.storage.notification, realm.storage.object, realm.storage.query, realm.storage.transaction, realm.sync, realm.sync.client, realm.sync.client.changeset, realm.sync.client.network, realm.sync.client.reset, realm.sync.client.session, realm.sync.server, ...
The
onRecord
stream now pumpsRealmLogRecord
s that include the category the message was logged to.If you want to hook up realm logging with conventional dart logging you can do:
Realm.logger.onRecord.forEach((r) => Logger(r.category.toString()).log(r.level.level, r.message));
If no isolate subscribes to
Realm.logger.onRecord
then the logs will by default be sent to stdout. (Issue #1578)
Enhancements
- Realm objects can now be serialized as EJSON. (Issue #1254)
import 'package:ejson/ejson.dart'; // ... class _Event { late DateTime timestamp; late String message; } // ... final ejson = toEJson(aRealmObject); final anUnmanagedRealmObject = fromEJson<Event>(ejson);
- Added
isCollectionDeleted
toRealmListChanges
,RealmSetChanges
, andRealmMapChanges
which will betrue
if the parent object, containing the collection has been deleted. (Core 14.0.0) - Added
isCleared
toRealmMapChanges
which will betrue
if the map has been cleared. (Core 14.0.0) - Querying a specific entry in a collection (in particular 'first and 'last') is supported. (Core 14.0.0)
class _Owner { late List<_Dog> dogs; } realm.query<Owner>('dogs[1].age = 5'); // Query all owners whose second dog element is 5 years old realm.query<Owner>('dogs[FIRST].age = 5'); // Query all owners whose first dog is 5 years old realm.query<Owner>('dogs[LAST].age = 5'); // Query all owners whose last dog is 5 years old realm.query<Owner>('dogs[SIZE] = 10'); // Query all owners who have 10 dogs
- Added support for storing lists and maps inside a
RealmValue
property. (Issue #1504)class _Container { late RealmValue anything; } realm.write(() { realm.add(Container(anything: RealmValue.from([1, 'foo', 3.14]))); }); final container = realm.all<Container>().first; final list = container.anything.asList(); // will throw if cast is invalid for (final item in containerValue) { switch (item.type) { case RealmValueType.int: print('Integer: ${item.value as int}'); break; case RealmValueType.string: print('String: ${item.value as String}'); break; case RealmValueType.double: print('Double: ${item.value as double}'); break; } } final subscription = list.changes.listen((event) { // The list changed });
- Added
RealmValueType
enum that contains all the possible types that can be wrapped by aRealmValue
. (PR #1469) - Added support for accessing
Set
andMap
types using the dynamic object API -obj.dynamic.getSet/getMap
. (PR #1533) - Added
RealmObjectBase.objectSchema
that returns the schema for this object. In most cases, this would be the schema defined in the model, but in case the Realm is opened as dynamic (by providing an empty collection for schemaObjects in the config) or usingFlexibleSyncConfiguration
, it may change as the schema on disk changes. (Issue #1449) - Added
Realm.schemaChanges
that returns a stream of schema changes that can be listened to. Only dynamic and synchronized Realms will emit schema changes. (Issue #1449) - Improve performance of object notifiers with complex schemas and very simple changes to process by as much as 20% (Core 14.2.0).
- Improve performance with very large number of notifiers as much as 75% (Core 14.2.0).
Fixed
- If you have more than 8388606 links pointing to one specific object, the program will crash. (Core 14.0.0)
- A Realm generated on a non-apple ARM 64 device and copied to another platform (and vice-versa) were non-portable due to a sorting order difference. This impacts strings or binaries that have their first difference at a non-ascii character. These items may not be found in a set, or in an indexed column if the strings had a long common prefix (> 200 characters). (Core 14.0.0)
- Ctor arguments appear in random order on generated classes, if the realm model contains many properties. (PR #1531)
- Fixed an issue where removing realm objects from a List with more than 1000 items could crash. (Core 14.2.0)
- Fix a spurious crash related to opening a Realm on background thread while the process was in the middle of exiting. (Core v14.3.0)
- Fixed conflict resolution bug which may result in an crash when the AddInteger instruction on Mixed properties is merged against updates to a non-integer type. (Core v14.3.0)
Compatibility
- Realm Studio: 14.0.0 or later.
- Fileformat: Generates files with format v24. Reads and automatically upgrade from fileformat v10. If you want to upgrade from an earlier file format version you will have to use RealmCore v13.x.y or earlier.
Internal
- Using Core v14.3.0
2.0.0-beta.1
2.0.0-beta.1 (2024-03-18)
Breaking Changes
-
RealmValue.type
is now an enum of typeRealmValueType
rather thanType
. If you need the runtime type of the value wrapped inRealmValue
, useRealmValue.value.runtimeType
. (Issue #1505) -
Renamed
RealmValue.uint8List
constructor toRealmValue.binary
. (PR #1469) -
Removed the following deprecated classes and members:
AppConfiguration.localAppName
- was unused and had no effectAppConfiguration.localAppVersion
- was unused and had no effectClientResetError.isFatal
- it was alwaystrue
ClientResetError.sessionErrorCode
SyncError.codeValue
- can be accessed throughSyncError.code.code
SyncError.category
- categories were deprecated in1.6.0
SyncError.detailedMessage
- was always emptySyncError
constructor andSyncError.create
factory - sync errors are created internally by the SDK and are not supposed to be constructed by usersSyncClientError
,SyncConnectionError
,SyncSessionError
,SyncResolveError
,SyncWebSocketError
,GeneralSyncError
- consolidated intoSyncError
as part of the error simplification in1.6.0
RealmProperty.indexed
- replaced byRealmProperty.indexType
SyncErrorCategory
,SyncClientErrorCode
,SyncConnectionErrorCode
,SyncSessionErrorCode
,SyncResolveErrorCode
,SyncWebsocketErrorCode
,GeneralSyncErrorCode
- consolidated intoSyncErrorCode
as part of the error simplification in1.6.0
User.provider
- the provider is associated with each identity, so the value was incorrect for users who had more than one identity
-
The generated parts are now named
.realm.dart
instead of.g.dart
. This is because the builder is now aPartBuilder
, instead of aSharedPartBuilder
. To migrate to this version you need to update all the part declarations to match, ie.part 'x.g.dart
becomespart x.realm.dart
and rerun the generator.This makes it easier to combine builders. Here is an example of combining with
dart_mappable
:import 'package:dart_mappable/dart_mappable.dart'; import 'package:realm_dart/realm.dart'; part 'part_builder.realm.dart'; part 'part_builder.mapper.dart'; @MappableClass() @RealmModel() class $Stuff with $StuffMappable { @MappableField() late int id; @override String toString() => 'Stuff{id: $id}'; } final realm = Realm(Configuration.local([Stuff.schema])); void main(List<String> arguments) { final s = realm.write(() => realm.add(Stuff(1), update: true)); print(s.toJson()); // <-- realm object as json Realm.shutdown(); }
-
Removed
SchemaObject.properties
- instead,SchemaObject
is now an iterable collection ofProperty
. (Issue #1449) -
SyncProgress.transferredBytes
andSyncProgress.transferableBytes
have been consolidated intoSyncProgress.progressEstimate
. The values reported previously were incorrect and did not accurately represent bytes either. The new field better conveys the uncertainty around the progress being reported. With this release, we're reporting accurate estimates for upload progress, but estimating downloads is still unreliable. A future server and SDK release will add better estimations for download progress. (Issue #1562)
Enhancements
-
Realm objects can now be serialized as EJSON
import 'package:ejson/ejson.dart'; // ... class _Event { late DateTime timestamp; late String message; } // ... final ejson = toEJson(aRealmObject); final anUnmanagedRealmObject = fromEJson<Event>(ejson);
-
Added
isCollectionDeleted
toRealmListChanges
,RealmSetChanges
, andRealmMapChanges
which will betrue
if the parent object, containing the collection has been deleted. (Core 14.0.0) -
Added
isCleared
toRealmMapChanges
which will betrue
if the map has been cleared. (Core 14.0.0) -
Querying a specific entry in a collection (in particular 'first and 'last') is supported. (Core 14.0.0)
class _Owner { late List<_Dog> dogs; } realm.query<Owner>('dogs[1].age = 5'); // Query all owners whose second dog element is 5 years old realm.query<Owner>('dogs[FIRST].age = 5'); // Query all owners whose first dog is 5 years old realm.query<Owner>('dogs[LAST].age = 5'); // Query all owners whose last dog is 5 years old realm.query<Owner>('dogs[SIZE] = 10'); // Query all owners who have 10 dogs
-
Added support for storing lists and maps inside a
RealmValue
property. (Issue #1504)class _Container { late RealmValue anything; } realm.write(() { realm.add(Container(anything: RealmValue.from([1, 'foo', 3.14]))); }); final container = realm.all<Container>().first; final list = container.anything.asList(); // will throw if cast is invalid for (final item in containerValue) { switch (item.type) { case RealmValueType.int: print('Integer: ${item.value as int}'); break; case RealmValueType.string: print('String: ${item.value as String}'); break; case RealmValueType.double: print('Double: ${item.value as double}'); break; } } final subscription = list.changes.listen((event) { // The list changed });
-
Added
RealmValueType
enum that contains all the possible types that can be wrapped by aRealmValue
. (PR #1469) -
Added support for accessing
Set
andMap
types using the dynamic object API -obj.dynamic.getSet/getMap
. (PR #1533) -
Added
RealmObjectBase.objectSchema
that returns the schema for this object. In most cases, this would be the schema defined in the model, but in case the Realm is opened as dynamic (by providing an empty collection for schemaObjects in the config) or usingFlexibleSyncConfiguration
, it may change as the schema on disk changes. (Issue #1449) -
Added
Realm.schemaChanges
that returns a stream of schema changes that can be listened to. Only dynamic and synchronized Realms will emit schema changes. (Issue #1449) -
Improve performance of object notifiers with complex schemas and very simple changes to process by as much as 20% ([Core 14.2.0).
-
Improve performance with very large number of notifiers as much as 75% (Core 14.2.0).
-
Add support to synchronize collections embedded in Mixed properties and other collections (except sets) (Core v14.2.0-12-g95c6efce8).
-
Improve performance of change notifications on nested collections somewhat (Core v14.2.0-12-g95c6efce8).
-
Improve performance of aggregate operations on Dictionaries of objects, particularly when the dictionaries are empty (Core v14.2.0-12-g95c6efce8)
Fixed
- If you have more than 8388606 links pointing to one specific object, the program will crash. (Core 14.0.0)
- A Realm generated on a non-apple ARM 64 device and copied to another platform (and vice-versa) were non-portable due to a sorting order difference. This impacts strings or binaries that have their first difference at a non-ascii character. These items may not be found in a set, or in an indexed column if the strings had a long common prefix (> 200 characters). (Core 14.0.0)
- Ctor arguments appear in random order on generated classes, if the realm model contains many properties. (PR #1531)
- Fixed an issue where removing realm objects from a List with more than 1000 items could crash. (Core 14.2.0)
- Fix a spurious crash related to opening a Realm on background thread while the process was in the middle of exiting (Core v14.2.0-12-g95c6efce8)
Compatibility
- Realm Studio: 14.0.0 or later.
- Fileformat: Generates files with format v24. Reads and automatically upgrade from fileformat v10. If you want to upgrade from an earlier file format version you will have to use RealmCore v13.x.y or earlier.
Internal
- Using Core v14.2.0-12-g95c6efce8
2.0.0-alpha.5
2.0.0-alpha.5 (2024-03-15)
Breaking Changes
-
RealmValue.type
is now an enum of typeRealmValueType
rather thanType
. If you need the runtime type of the value wrapped inRealmValue
, useRealmValue.value.runtimeType
. (Issue #1505) -
Renamed
RealmValue.uint8List
constructor toRealmValue.binary
. (PR #1469) -
Removed the following deprecated classes and members:
AppConfiguration.localAppName
- was unused and had no effectAppConfiguration.localAppVersion
- was unused and had no effectClientResetError.isFatal
- it was alwaystrue
ClientResetError.sessionErrorCode
SyncError.codeValue
- can be accessed throughSyncError.code.code
SyncError.category
- categories were deprecated in1.6.0
SyncError.detailedMessage
- was always emptySyncError
constructor andSyncError.create
factory - sync errors are created internally by the SDK and are not supposed to be constructed by usersSyncClientError
,SyncConnectionError
,SyncSessionError
,SyncResolveError
,SyncWebSocketError
,GeneralSyncError
- consolidated intoSyncError
as part of the error simplification in1.6.0
RealmProperty.indexed
- replaced byRealmProperty.indexType
SyncErrorCategory
,SyncClientErrorCode
,SyncConnectionErrorCode
,SyncSessionErrorCode
,SyncResolveErrorCode
,SyncWebsocketErrorCode
,GeneralSyncErrorCode
- consolidated intoSyncErrorCode
as part of the error simplification in1.6.0
User.provider
- the provider is associated with each identity, so the value was incorrect for users who had more than one identity
-
The generated parts are now named
.realm.dart
instead of.g.dart
. This is because the builder is now aPartBuilder
, instead of aSharedPartBuilder
. To migrate to this version you need to update all the part declarations to match, ie.part 'x.g.dart
becomespart x.realm.dart
and rerun the generator.This makes it easier to combine builders. Here is an example of combining with
dart_mappable
:import 'package:dart_mappable/dart_mappable.dart'; import 'package:realm_dart/realm.dart'; part 'part_builder.realm.dart'; part 'part_builder.mapper.dart'; @MappableClass() @RealmModel() class $Stuff with $StuffMappable { @MappableField() late int id; @override String toString() => 'Stuff{id: $id}'; } final realm = Realm(Configuration.local([Stuff.schema])); void main(List<String> arguments) { final s = realm.write(() => realm.add(Stuff(1), update: true)); print(s.toJson()); // <-- realm object as json Realm.shutdown(); }
-
Removed
SchemaObject.properties
- instead,SchemaObject
is now an iterable collection ofProperty
. (Issue #1449) -
SyncProgress.transferredBytes
andSyncProgress.transferableBytes
have been consolidated intoSyncProgress.progressEstimate
. The values reported previously were incorrect and did not accurately represent bytes either. The new field better conveys the uncertainty around the progress being reported. With this release, we're reporting accurate estimates for upload progress, but estimating downloads is still unreliable. A future server and SDK release will add better estimations for download progress. (Issue #1562)
Enhancements
-
Realm objects can now be serialized as EJSON
import 'package:ejson/ejson.dart'; // ... class _Event { late DateTime timestamp; late String message; } // ... final ejson = toEJson(aRealmObject); final anUnmanagedRealmObject = fromEJson<Event>(ejson);
-
Added
isCollectionDeleted
toRealmListChanges
,RealmSetChanges
, andRealmMapChanges
which will betrue
if the parent object, containing the collection has been deleted. (Core 14.0.0) -
Added
isCleared
toRealmMapChanges
which will betrue
if the map has been cleared. (Core 14.0.0) -
Querying a specific entry in a collection (in particular 'first and 'last') is supported. (Core 14.0.0)
class _Owner { late List<_Dog> dogs; } realm.query<Owner>('dogs[1].age = 5'); // Query all owners whose second dog element is 5 years old realm.query<Owner>('dogs[FIRST].age = 5'); // Query all owners whose first dog is 5 years old realm.query<Owner>('dogs[LAST].age = 5'); // Query all owners whose last dog is 5 years old realm.query<Owner>('dogs[SIZE] = 10'); // Query all owners who have 10 dogs
-
Added support for storing lists and maps inside a
RealmValue
property. (Issue #1504)class _Container { late RealmValue anything; } realm.write(() { realm.add(Container(anything: RealmValue.from([1, 'foo', 3.14]))); }); final container = realm.all<Container>().first; final list = container.anything.asList(); // will throw if cast is invalid for (final item in containerValue) { switch (item.type) { case RealmValueType.int: print('Integer: ${item.value as int}'); break; case RealmValueType.string: print('String: ${item.value as String}'); break; case RealmValueType.double: print('Double: ${item.value as double}'); break; } } final subscription = list.changes.listen((event) { // The list changed });
-
Added
RealmValueType
enum that contains all the possible types that can be wrapped by aRealmValue
. (PR #1469) -
Added support for accessing
Set
andMap
types using the dynamic object API -obj.dynamic.getSet/getMap
. (PR #1533) -
Added
RealmObjectBase.objectSchema
that returns the schema for this object. In most cases, this would be the schema defined in the model, but in case the Realm is opened as dynamic (by providing an empty collection for schemaObjects in the config) or usingFlexibleSyncConfiguration
, it may change as the schema on disk changes. (Issue #1449) -
Added
Realm.schemaChanges
that returns a stream of schema changes that can be listened to. Only dynamic and synchronized Realms will emit schema changes. (Issue #1449) -
Improve performance of object notifiers with complex schemas and very simple changes to process by as much as 20% ([Core 14.2.0).
-
Improve performance with very large number of notifiers as much as 75% (Core 14.2.0).
-
Add support to synchronize collections embedded in Mixed properties and other collections (except sets) (Core v14.2.0-12-g95c6efce8).
-
Improve performance of change notifications on nested collections somewhat (Core v14.2.0-12-g95c6efce8).
-
Improve performance of aggregate operations on Dictionaries of objects, particularly when the dictionaries are empty (Core v14.2.0-12-g95c6efce8)
Fixed
- If you have more than 8388606 links pointing to one specific object, the program will crash. (Core 14.0.0)
- A Realm generated on a non-apple ARM 64 device and copied to another platform (and vice-versa) were non-portable due to a sorting order difference. This impacts strings or binaries that have their first difference at a non-ascii character. These items may not be found in a set, or in an indexed column if the strings had a long common prefix (> 200 characters). (Core 14.0.0)
- Ctor arguments appear in random order on generated classes, if the realm model contains many properties. (PR #1531)
- Fixed an issue where removing realm objects from a List with more than 1000 items could crash. (Core 14.2.0)
- Fix a spurious crash related to opening a Realm on background thread while the process was in the middle of exiting (Core v14.2.0-12-g95c6efce8)
Compatibility
- Realm Studio: 14.0.0 or later.
- Fileformat: Generates files with format v24. Reads and automatically upgrade from fileformat v10. If you want to upgrade from an earlier file format version you will have to use RealmCore v13.x.y or earlier.
Internal
- Using Core v14.2.0-12-g95c6efce8
1.9.0
1.9.0 (2024-02-02)
Enhancements
- Added
User.changes
stream that allows subscribers to receive notifications when the User changes - for example when the user's custom data changes or when their authentication state changes. (PR #1500) - Allow the query builder to construct >, >=, <, <= queries for string constants. This is a case sensitive lexicographical comparison. Improved performance of RQL queries on a non-linked string property using: >, >=, <, <=, operators and fixed behaviour that a null string should be evaulated as less than everything, previously nulls were not matched. (Core 13.26.0-13-gd12c3)
Fixed
- Creating an
AppConfiguration
with an empty appId will now throw an exception rather than crashing the app. (Issue #1487) - Uploading the changesets recovered during an automatic client reset recovery may lead to 'Bad server version' errors and a new client reset. (Core 13.26.0-13-gd12c3)
Compatibility
- Realm Studio: 13.0.0 or later.
Internal
- Using Core 13.26.0-13-gd12c3
1.8.0
1.8.0 (2024-01-29)
Enhancements
- Added
RealmObject.getBacklinks<SourceType>('sourceProperty')
which is a method allowing you to look up all objects of typeSourceType
which link to the current object via theirsourceProperty
property. (Issue #1480) - Added
App.updateBaseUrl
method for updating the App's base URL for switching between cloud and edge servers. The current Sync Session(s) must be paused before calling this method and the user must log in again afterwards before the Sync Session can be resumed. (PR #1454)
Fixed
- Fix a possible hang (or in rare cases crash) during notification handling. (Issue #1492)
- Fix Flutter app build on Linux. A contribution from thiagokisaki. (PR #1488)
- App was not using the current baseUrl value from AppConfiguration when it is created and always used the cached value stored upon the first contact with the server. (Core XX.XX.X)
Compatibility
- Realm Studio: 13.0.0 or later.
Internal
- Using Core 13.26.0