Repository navigation
2.0.0
2.0.0 (2024-03-20)
Breaking Changes
-
RealmValue.typeis now an enum of typeRealmValueTyperather thanType. If you need the runtime type of the value wrapped inRealmValue, useRealmValue.value.runtimeType. (Issue #1505) -
Renamed
RealmValue.uint8Listconstructor 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 alwaystrueClientResetError.sessionErrorCodeSyncError.codeValue- can be accessed throughSyncError.code.codeSyncError.category- categories were deprecated in1.6.0SyncError.detailedMessage- was always emptySyncErrorconstructor andSyncError.createfactory - sync errors are created internally by the SDK and are not supposed to be constructed by usersSyncClientError,SyncConnectionError,SyncSessionError,SyncResolveError,SyncWebSocketError,GeneralSyncError- consolidated intoSyncErroras part of the error simplification in1.6.0RealmProperty.indexed- replaced byRealmProperty.indexTypeSyncErrorCategory,SyncClientErrorCode,SyncConnectionErrorCode,SyncSessionErrorCode,SyncResolveErrorCode,SyncWebsocketErrorCode,GeneralSyncErrorCode- consolidated intoSyncErrorCodeas part of the error simplification in1.6.0User.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.dartinstead 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.dartbecomespart x.realm.dartand 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,SchemaObjectis now an iterable collection ofProperty. (Issue #1449) -
SyncProgress.transferredBytesandSyncProgress.transferableByteshave 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.loggeris no longer settable, and no longer implementsLoggerfrom 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.realmis 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
onRecordstream now pumpsRealmLogRecords 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.onRecordthen 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
isCollectionDeletedtoRealmListChanges,RealmSetChanges, andRealmMapChangeswhich will betrueif the parent object, containing the collection has been deleted. (Core 14.0.0) - Added
isClearedtoRealmMapChangeswhich will betrueif 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
RealmValueproperty. (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
RealmValueTypeenum that contains all the possible types that can be wrapped by aRealmValue. (PR #1469) - Added support for accessing
SetandMaptypes using the dynamic object API -obj.dynamic.getSet/getMap. (PR #1533) - Added
RealmObjectBase.objectSchemathat 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.schemaChangesthat 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