diff --git a/packages/ejson/pubspec.yaml b/packages/ejson/pubspec.yaml index cabf25f25..6539207d8 100644 --- a/packages/ejson/pubspec.yaml +++ b/packages/ejson/pubspec.yaml @@ -28,5 +28,5 @@ dependencies: dev_dependencies: build_runner: ^2.0.0 ejson_generator: ^0.4.0 - lints: ^3.0.0 + lints: ^5.0.0 test: ^1.21.0 diff --git a/packages/ejson_analyzer/pubspec.yaml b/packages/ejson_analyzer/pubspec.yaml index a510307f0..f558f9b66 100644 --- a/packages/ejson_analyzer/pubspec.yaml +++ b/packages/ejson_analyzer/pubspec.yaml @@ -12,10 +12,10 @@ environment: sdk: ^3.3.0 dependencies: - analyzer: ^6.0.0 + analyzer: ^7.0.0 ejson_annotation: ^0.4.0 - source_gen: ^1.3.2 + source_gen: ^2.0.0 dev_dependencies: - lints: ^3.0.0 + lints: ^5.0.0 test: ^1.21.0 diff --git a/packages/ejson_annotation/pubspec.yaml b/packages/ejson_annotation/pubspec.yaml index 78ff536f8..b05a0d618 100644 --- a/packages/ejson_annotation/pubspec.yaml +++ b/packages/ejson_annotation/pubspec.yaml @@ -12,4 +12,4 @@ environment: sdk: ^3.3.0 dev_dependencies: - lints: ^3.0.0 + lints: ^5.0.0 diff --git a/packages/ejson_generator/pubspec.yaml b/packages/ejson_generator/pubspec.yaml index 4380d205e..320604e27 100644 --- a/packages/ejson_generator/pubspec.yaml +++ b/packages/ejson_generator/pubspec.yaml @@ -19,17 +19,17 @@ environment: sdk: ^3.3.0 dependencies: - analyzer: ^6.0.0 + analyzer: ^7.0.0 build: ^2.4.0 ejson_analyzer: ^0.4.0 - source_gen: ^1.3.2 + source_gen: ^2.0.0 dev_dependencies: build_runner: ^2.4.4 build_test: ^2.1.7 - dart_style: ^2.3.1 + dart_style: ^3.0.1 ejson: ^0.4.0 ejson_annotation: ^0.4.0 - lints: ^3.0.0 + lints: ^5.0.0 meta: ^1.9.1 test: ^1.21.0 diff --git a/packages/ejson_generator/test/compile_test.dart b/packages/ejson_generator/test/compile_test.dart index c4006b073..762b314c7 100644 --- a/packages/ejson_generator/test/compile_test.dart +++ b/packages/ejson_generator/test/compile_test.dart @@ -6,8 +6,9 @@ import 'package:ejson_generator/ejson_generator.dart'; import 'package:source_gen/source_gen.dart'; import 'package:test/test.dart'; import 'package:meta/meta.dart'; +import 'package:pub_semver/pub_semver.dart'; -final _formatter = DartFormatter(lineEnding: '\n'); +final _formatter = DartFormatter(lineEnding: '\n', languageVersion: Version(3, 3, 0)); final _tag = RegExp(r'// \*.*\n// EJsonGenerator\n// \*.*'); @isTest diff --git a/packages/ejson_generator/test/ctor_test.g.dart b/packages/ejson_generator/test/ctor_test.g.dart index c0d5dd4c4..6d5aa30b7 100644 --- a/packages/ejson_generator/test/ctor_test.g.dart +++ b/packages/ejson_generator/test/ctor_test.g.dart @@ -66,14 +66,15 @@ EJsonValue _encodeRequiredNamedParameters(RequiredNamedParameters value) { RequiredNamedParameters _decodeRequiredNamedParameters(EJsonValue ejson) { return switch (ejson) { - {'requiredNamed': EJsonValue requiredNamed} => - RequiredNamedParameters(requiredNamed: fromEJson(requiredNamed)), + {'requiredNamed': EJsonValue requiredNamed} => RequiredNamedParameters( + requiredNamed: fromEJson(requiredNamed), + ), _ => raiseInvalidEJson(ejson), }; } extension RequiredNamedParametersEJsonEncoderExtension - on RequiredNamedParameters { +on RequiredNamedParameters { @pragma('vm:prefer-inline') EJsonValue toEJson() => _encodeRequiredNamedParameters(this); } @@ -87,14 +88,15 @@ EJsonValue _encodeOptionalNamedParameters(OptionalNamedParameters value) { OptionalNamedParameters _decodeOptionalNamedParameters(EJsonValue ejson) { return switch (ejson) { - {'optionalNamed': EJsonValue optionalNamed} => - OptionalNamedParameters(optionalNamed: fromEJson(optionalNamed)), + {'optionalNamed': EJsonValue optionalNamed} => OptionalNamedParameters( + optionalNamed: fromEJson(optionalNamed), + ), _ => raiseInvalidEJson(ejson), }; } extension OptionalNamedParametersEJsonEncoderExtension - on OptionalNamedParameters { +on OptionalNamedParameters { @pragma('vm:prefer-inline') EJsonValue toEJson() => _encodeOptionalNamedParameters(this); } @@ -108,8 +110,9 @@ EJsonValue _encodeOptionalParameters(OptionalParameters value) { OptionalParameters _decodeOptionalParameters(EJsonValue ejson) { return switch (ejson) { - {'optional': EJsonValue optional} => - OptionalParameters(fromEJson(optional)), + {'optional': EJsonValue optional} => OptionalParameters( + fromEJson(optional), + ), _ => raiseInvalidEJson(ejson), }; } @@ -147,21 +150,26 @@ EJsonValue _encodePerson(Person value) { 'birthDate': value.birthDate.toEJson(), 'income': value.income.toEJson(), 'spouse': value.spouse.toEJson(), - 'cprNumber': value.cprNumber.toEJson() + 'cprNumber': value.cprNumber.toEJson(), }; } Person _decodePerson(EJsonValue ejson) { return switch (ejson) { { - 'name': EJsonValue name, - 'birthDate': EJsonValue birthDate, - 'income': EJsonValue income, - 'spouse': EJsonValue spouse, - 'cprNumber': EJsonValue cprNumber + 'name': EJsonValue name, + 'birthDate': EJsonValue birthDate, + 'income': EJsonValue income, + 'spouse': EJsonValue spouse, + 'cprNumber': EJsonValue cprNumber, } => - Person(fromEJson(name), fromEJson(birthDate), fromEJson(income), - spouse: fromEJson(spouse), cprNumber: fromEJson(cprNumber)), + Person( + fromEJson(name), + fromEJson(birthDate), + fromEJson(income), + spouse: fromEJson(spouse), + cprNumber: fromEJson(cprNumber), + ), _ => raiseInvalidEJson(ejson), }; } diff --git a/packages/ejson_lint/lib/src/lints/mismatched_getter_type.dart b/packages/ejson_lint/lib/src/lints/mismatched_getter_type.dart index 2712b49e1..5b51aee15 100644 --- a/packages/ejson_lint/lib/src/lints/mismatched_getter_type.dart +++ b/packages/ejson_lint/lib/src/lints/mismatched_getter_type.dart @@ -27,13 +27,13 @@ class MismatchedGetterType extends DartLintRule { final ctor = node.declaredElement; if (ctor == null) return; // not resolved; if (isEJsonAnnotated(ctor)) { - final cls = ctor.enclosingElement as ClassElement; + final cls = ctor.enclosingElement3 as ClassElement; for (final param in ctor.parameters) { final getter = cls.getGetter(param.name); if (getter == null) continue; if (getter.returnType != param.type) { - reporter.reportErrorForElement(code, getter); - reporter.reportErrorForElement(code, param); + reporter.atElement(getter, code); + reporter.atElement(param, code); } } } diff --git a/packages/ejson_lint/lib/src/lints/missing_getter.dart b/packages/ejson_lint/lib/src/lints/missing_getter.dart index 0b26c85b9..f774717d5 100644 --- a/packages/ejson_lint/lib/src/lints/missing_getter.dart +++ b/packages/ejson_lint/lib/src/lints/missing_getter.dart @@ -27,10 +27,10 @@ class MissingGetter extends DartLintRule { final ctor = node.declaredElement; if (ctor == null) return; // not resolved; if (isEJsonAnnotated(ctor)) { - final cls = ctor.enclosingElement as ClassElement; + final cls = ctor.enclosingElement3 as ClassElement; for (final param in ctor.parameters) { final getter = cls.getGetter(param.name); - if (getter == null) reporter.reportErrorForElement(code, param); + if (getter == null) reporter.atElement(param, code); } } }); diff --git a/packages/ejson_lint/lib/src/lints/too_many_annotated_constructors.dart b/packages/ejson_lint/lib/src/lints/too_many_annotated_constructors.dart index 4749825a3..35fcc0a49 100644 --- a/packages/ejson_lint/lib/src/lints/too_many_annotated_constructors.dart +++ b/packages/ejson_lint/lib/src/lints/too_many_annotated_constructors.dart @@ -38,7 +38,7 @@ class TooManyAnnotatedConstructors extends DartLintRule { final annotatedConstructors = cls.constructors.where((ctor) => isEJsonAnnotated(ctor)); if (annotatedConstructors.length > 1) { for (final ctor in annotatedConstructors) { - reporter.reportErrorForElement(code, ctor); + reporter.atElement(ctor, code); } } }); diff --git a/packages/realm_dart/dev/lib/src/build.dart b/packages/realm_dart/dev/lib/src/build.dart index 59b03a918..9102f060f 100644 --- a/packages/realm_dart/dev/lib/src/build.dart +++ b/packages/realm_dart/dev/lib/src/build.dart @@ -204,7 +204,7 @@ class BuildNativeCommand extends BaseCommand { final iosSdkOptions = argResults['ios-sdk'] as List; final iosSdks = iosSdkOptions.contains('all') // if 'all' is specified, build for all available SDKs ? iOSSdk.values - : iosSdkOptions.map((o) => iOSSdk.from(o)).whereNotNull(); + : iosSdkOptions.map((o) => iOSSdk.from(o)).nonNulls; for (final target in targets) { logger.info('Building for ${target.name} in ${buildMode.name} mode'); diff --git a/packages/realm_dart/test/backlinks_test.dart b/packages/realm_dart/test/backlinks_test.dart index 425ba546f..0e3f1ec20 100644 --- a/packages/realm_dart/test/backlinks_test.dart +++ b/packages/realm_dart/test/backlinks_test.dart @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 import 'package:realm_dart/realm.dart'; -import 'package:test/test.dart' hide test, throws; import 'test.dart'; diff --git a/packages/realm_dart/test/geospatial_test.dart b/packages/realm_dart/test/geospatial_test.dart index b1a4b01f9..841ca4e3b 100644 --- a/packages/realm_dart/test/geospatial_test.dart +++ b/packages/realm_dart/test/geospatial_test.dart @@ -4,9 +4,6 @@ import 'dart:async'; import 'dart:math'; -import 'package:realm_common/realm_common.dart'; -import 'package:test/test.dart' hide test, throws; - import 'package:realm_dart/realm.dart'; import 'test.dart'; diff --git a/packages/realm_dart/test/indexed_test.dart b/packages/realm_dart/test/indexed_test.dart index 242c6b9ee..47944b57a 100644 --- a/packages/realm_dart/test/indexed_test.dart +++ b/packages/realm_dart/test/indexed_test.dart @@ -4,7 +4,6 @@ import 'dart:math'; import 'dart:typed_data'; -import 'package:test/test.dart' hide test, throws; import 'test.dart'; import 'package:realm_dart/realm.dart'; diff --git a/packages/realm_dart/test/list_test.dart b/packages/realm_dart/test/list_test.dart index 44d64afdb..7db934768 100644 --- a/packages/realm_dart/test/list_test.dart +++ b/packages/realm_dart/test/list_test.dart @@ -8,7 +8,6 @@ import 'dart:math'; import 'package:collection/collection.dart'; import 'package:meta/meta.dart'; -import 'package:test/test.dart' hide test, throws; import 'package:realm_dart/realm.dart'; import 'test.dart'; diff --git a/packages/realm_dart/test/migration_test.dart b/packages/realm_dart/test/migration_test.dart index 72179465c..f6c57b12a 100644 --- a/packages/realm_dart/test/migration_test.dart +++ b/packages/realm_dart/test/migration_test.dart @@ -4,7 +4,6 @@ // ignore_for_file: unused_local_variable import 'dart:async'; -import 'package:test/test.dart' hide test, throws; import 'package:realm_dart/realm.dart'; import 'test.dart'; import 'package:realm_dart/src/results.dart'; diff --git a/packages/realm_dart/test/realm_set_test.dart b/packages/realm_dart/test/realm_set_test.dart index f226cf425..f33ba23b4 100644 --- a/packages/realm_dart/test/realm_set_test.dart +++ b/packages/realm_dart/test/realm_set_test.dart @@ -5,7 +5,6 @@ import 'dart:typed_data'; import 'package:collection/collection.dart'; import 'package:realm_dart/realm.dart'; -import 'package:test/test.dart' hide test, throws; import 'test.dart'; diff --git a/packages/realm_dart/test/realm_value_test.dart b/packages/realm_dart/test/realm_value_test.dart index 08583d5e4..456fe80b1 100644 --- a/packages/realm_dart/test/realm_value_test.dart +++ b/packages/realm_dart/test/realm_value_test.dart @@ -7,7 +7,6 @@ import 'dart:typed_data'; import 'package:collection/collection.dart'; import 'package:realm_common/realm_common.dart' show memEquals; import 'package:realm_dart/realm.dart'; -import 'package:test/test.dart' hide test, throws; import 'test.dart'; diff --git a/packages/realm_dart/test/results_test.dart b/packages/realm_dart/test/results_test.dart index add587f33..1b8ca244c 100644 --- a/packages/realm_dart/test/results_test.dart +++ b/packages/realm_dart/test/results_test.dart @@ -4,7 +4,6 @@ // ignore_for_file: unused_local_variable import 'dart:typed_data'; -import 'package:test/test.dart' hide test, throws; import 'package:realm_dart/realm.dart'; import 'test.dart'; diff --git a/packages/realm_generator/lib/src/error.dart b/packages/realm_generator/lib/src/error.dart index f5c399d20..e290ac1a7 100644 --- a/packages/realm_generator/lib/src/error.dart +++ b/packages/realm_generator/lib/src/error.dart @@ -29,7 +29,7 @@ class RealmInvalidGenerationSourceError extends InvalidGenerationSourceError { color = color ?? session.color, super(element: element) { if (element is FieldElement || element is ConstructorElement) { - final classElement = element.enclosingElement!; + final classElement = element.enclosingElement3!; this.secondarySpans.addAll({ classElement.span!: "in realm model for '${session.mapping.entries.where((e) => e.value == classElement).singleOrNull?.key}'", }); diff --git a/packages/realm_generator/lib/src/field_element_ex.dart b/packages/realm_generator/lib/src/field_element_ex.dart index 4115c5a6a..34484d50c 100644 --- a/packages/realm_generator/lib/src/field_element_ex.dart +++ b/packages/realm_generator/lib/src/field_element_ex.dart @@ -24,7 +24,7 @@ import 'type_checkers.dart'; extension FieldElementEx on FieldElement { static const realmSetUnsupportedRealmTypes = [RealmPropertyType.linkingObjects]; - ClassElement get enclosingClassElement => enclosingElement as ClassElement; + ClassElement get enclosingClassElement => enclosingElement3 as ClassElement; FieldDeclaration get declarationAstNode => getDeclarationFromElement(this)!.node.parent!.parent as FieldDeclaration; @@ -163,7 +163,7 @@ extension FieldElementEx on FieldElement { String? linkOriginProperty; // Validate field type - final modelSpan = enclosingElement.span!; + final modelSpan = enclosingElement3.span!; final file = modelSpan.file; final realmType = type.realmType; if (realmType == null) { @@ -185,7 +185,7 @@ extension FieldElementEx on FieldElement { primarySpan: typeSpan(file), primaryLabel: '$modelTypeName is not a realm model type', secondarySpans: { - modelSpan: "in realm model '${enclosingElement.displayName}'", + modelSpan: "in realm model '${enclosingElement3.displayName}'", // may go both above and below, or stem from another file if (notARealmTypeSpan != null) notARealmTypeSpan: '' }, @@ -293,7 +293,7 @@ extension FieldElementEx on FieldElement { ); } - final thisType = (enclosingElement as ClassElement).thisType; + final thisType = (enclosingElement3 as ClassElement).thisType; final linkType = thisType.asNullable; final listOf = session.typeProvider.listType(thisType); if (sourceField.type != linkType && sourceField.type != listOf) { @@ -398,7 +398,7 @@ extension FieldElementEx on FieldElement { ParenthesizedExpression i => _isValidFieldInitializer(i.expression), PrefixExpression e => _isValidFieldInitializer(e.operand), BinaryExpression b => _isValidFieldInitializer(b.leftOperand) && _isValidFieldInitializer(b.rightOperand), - Identifier i => (i.staticElement as PropertyAccessorElement?)?.variable.isConst ?? false, + Identifier i => (i.staticElement as PropertyAccessorElement?)?.variable2?.isConst ?? false, _ => false, }; } diff --git a/packages/realm_generator/pubspec.yaml b/packages/realm_generator/pubspec.yaml index 2ccb3219e..d7615dcd3 100644 --- a/packages/realm_generator/pubspec.yaml +++ b/packages/realm_generator/pubspec.yaml @@ -13,19 +13,19 @@ environment: sdk: ^3.3.0 dependencies: - analyzer: ^6.0.0 + analyzer: ^7.0.0 build_resolvers: ^2.0.9 build: ^2.0.0 - dart_style: ^2.2.0 + dart_style: ^3.0.0 realm_common: ^20.0.1 - source_gen: ^1.1.0 + source_gen: ^2.0.0 source_span: ^1.8.0 collection: ^1.18.0 dev_dependencies: build_runner: ^2.1.0 build_test: ^2.1.4 - lints: ^3.0.0 + lints: ^5.0.0 logging: ^1.2.0 meta: ^1.7.0 path: ^1.0.0 diff --git a/packages/realm_generator/test/good_test_data/all_named_ctor.expected b/packages/realm_generator/test/good_test_data/all_named_ctor.expected index bf34026bf..d90e81ee5 100644 --- a/packages/realm_generator/test/good_test_data/all_named_ctor.expected +++ b/packages/realm_generator/test/good_test_data/all_named_ctor.expected @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'all_named_ctor.dart'; @@ -11,14 +12,9 @@ part of 'all_named_ctor.dart'; class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { static var _defaultsSet = false; - Person({ - required String name, - int age = 42, - }) { + Person({required String name, int age = 42}) { if (!_defaultsSet) { - _defaultsSet = RealmObjectBase.setDefaults({ - 'age': 42, - }); + _defaultsSet = RealmObjectBase.setDefaults({'age': 42}); } RealmObjectBase.set(this, 'name', name); RealmObjectBase.set(this, 'age', age); @@ -48,19 +44,14 @@ class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { Person freeze() => RealmObjectBase.freezeObject(this); EJsonValue toEJson() { - return { - 'name': name.toEJson(), - 'age': age.toEJson(), - }; + return {'name': name.toEJson(), 'age': age.toEJson()}; } static EJsonValue _toEJson(Person value) => value.toEJson(); static Person _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); return switch (ejson) { - { - 'name': EJsonValue name, - } => + {'name': EJsonValue name} => Person( name: fromEJson(name), age: fromEJson(ejson['age'], defaultValue: 42), diff --git a/packages/realm_generator/test/good_test_data/all_types.expected b/packages/realm_generator/test/good_test_data/all_types.expected index 8b244eb09..553771de9 100644 --- a/packages/realm_generator/test/good_test_data/all_types.expected +++ b/packages/realm_generator/test/good_test_data/all_types.expected @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'all_types.dart'; @@ -11,14 +12,9 @@ part of 'all_types.dart'; class Foo extends _Foo with RealmEntity, RealmObjectBase, RealmObject { static var _defaultsSet = false; - Foo({ - int x = 0, - Bar? bar, - }) { + Foo({int x = 0, Bar? bar}) { if (!_defaultsSet) { - _defaultsSet = RealmObjectBase.setDefaults({ - 'x': 0, - }); + _defaultsSet = RealmObjectBase.setDefaults({'x': 0}); } RealmObjectBase.set(this, 'x', x); RealmObjectBase.set(this, 'bar', bar); @@ -48,10 +44,7 @@ class Foo extends _Foo with RealmEntity, RealmObjectBase, RealmObject { Foo freeze() => RealmObjectBase.freezeObject(this); EJsonValue toEJson() { - return { - 'x': x.toEJson(), - 'bar': bar.toEJson(), - }; + return {'x': x.toEJson(), 'bar': bar.toEJson()}; } static EJsonValue _toEJson(Foo value) => value.toEJson(); @@ -67,10 +60,17 @@ class Foo extends _Foo with RealmEntity, RealmObjectBase, RealmObject { RealmObjectBase.registerFactory(Foo._); register(_toEJson, _fromEJson); return const SchemaObject(ObjectType.realmObject, Foo, 'MyFoo', [ - SchemaProperty('x', RealmPropertyType.int, - indexType: RealmIndexType.regular), - SchemaProperty('bar', RealmPropertyType.object, - optional: true, linkTarget: 'Bar'), + SchemaProperty( + 'x', + RealmPropertyType.int, + indexType: RealmIndexType.regular, + ), + SchemaProperty( + 'bar', + RealmPropertyType.object, + optional: true, + linkTarget: 'Bar', + ), ]); }(); @@ -100,9 +100,7 @@ class Bar extends _Bar with RealmEntity, RealmObjectBase, RealmObject { Iterable manyAny = const [], }) { if (!_defaultsSet) { - _defaultsSet = RealmObjectBase.setDefaults({ - 'aDouble': 0.0, - }); + _defaultsSet = RealmObjectBase.setDefaults({'aDouble': 0.0}); } RealmObjectBase.set(this, 'name', name); RealmObjectBase.set(this, 'aBool', aBool); @@ -119,7 +117,10 @@ class Bar extends _Bar with RealmEntity, RealmObjectBase, RealmObject { RealmObjectBase.set(this, 'anOptionalString', anOptionalString); RealmObjectBase.set(this, 'any', any); RealmObjectBase.set>( - this, 'manyAny', RealmList(manyAny)); + this, + 'manyAny', + RealmList(manyAny), + ); RealmObjectBase.set(this, 'decimal', decimal); } @@ -303,36 +304,76 @@ class Bar extends _Bar with RealmEntity, RealmObjectBase, RealmObject { register(_toEJson, _fromEJson); return const SchemaObject(ObjectType.realmObject, Bar, 'Bar', [ SchemaProperty('name', RealmPropertyType.string, primaryKey: true), - SchemaProperty('aBool', RealmPropertyType.bool, - indexType: RealmIndexType.regular), - SchemaProperty('another', RealmPropertyType.bool, - indexType: RealmIndexType.regular), + SchemaProperty( + 'aBool', + RealmPropertyType.bool, + indexType: RealmIndexType.regular, + ), + SchemaProperty( + 'another', + RealmPropertyType.bool, + indexType: RealmIndexType.regular, + ), SchemaProperty('data', RealmPropertyType.binary), - SchemaProperty('timestamp', RealmPropertyType.timestamp, - mapTo: 'tidspunkt', indexType: RealmIndexType.regular), + SchemaProperty( + 'timestamp', + RealmPropertyType.timestamp, + mapTo: 'tidspunkt', + indexType: RealmIndexType.regular, + ), SchemaProperty('aDouble', RealmPropertyType.double), - SchemaProperty('foo', RealmPropertyType.object, - optional: true, linkTarget: 'MyFoo'), - SchemaProperty('objectId', RealmPropertyType.objectid, - indexType: RealmIndexType.regular), - SchemaProperty('uuid', RealmPropertyType.uuid, - indexType: RealmIndexType.regular), - SchemaProperty('list', RealmPropertyType.int, - collectionType: RealmCollectionType.list), - SchemaProperty('set', RealmPropertyType.int, - collectionType: RealmCollectionType.set), - SchemaProperty('map', RealmPropertyType.int, - collectionType: RealmCollectionType.map), - SchemaProperty('anOptionalString', RealmPropertyType.string, - optional: true, indexType: RealmIndexType.regular), + SchemaProperty( + 'foo', + RealmPropertyType.object, + optional: true, + linkTarget: 'MyFoo', + ), + SchemaProperty( + 'objectId', + RealmPropertyType.objectid, + indexType: RealmIndexType.regular, + ), + SchemaProperty( + 'uuid', + RealmPropertyType.uuid, + indexType: RealmIndexType.regular, + ), + SchemaProperty( + 'list', + RealmPropertyType.int, + collectionType: RealmCollectionType.list, + ), + SchemaProperty( + 'set', + RealmPropertyType.int, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'map', + RealmPropertyType.int, + collectionType: RealmCollectionType.map, + ), + SchemaProperty( + 'anOptionalString', + RealmPropertyType.string, + optional: true, + indexType: RealmIndexType.regular, + ), SchemaProperty('any', RealmPropertyType.mixed, optional: true), - SchemaProperty('manyAny', RealmPropertyType.mixed, - optional: true, collectionType: RealmCollectionType.list), + SchemaProperty( + 'manyAny', + RealmPropertyType.mixed, + optional: true, + collectionType: RealmCollectionType.list, + ), SchemaProperty('decimal', RealmPropertyType.decimal128), - SchemaProperty('foos', RealmPropertyType.linkingObjects, - linkOriginProperty: 'bar', - collectionType: RealmCollectionType.list, - linkTarget: 'MyFoo'), + SchemaProperty( + 'foos', + RealmPropertyType.linkingObjects, + linkOriginProperty: 'bar', + collectionType: RealmCollectionType.list, + linkTarget: 'MyFoo', + ), ]); }(); @@ -395,8 +436,9 @@ class PrimitiveTypes extends _PrimitiveTypes RealmObjectBase.getChanges(this); @override - Stream> changesFor( - [List? keyPaths]) => + Stream> changesFor([ + List? keyPaths, + ]) => RealmObjectBase.getChangesFor(this, keyPaths); @override @@ -438,13 +480,17 @@ class PrimitiveTypes extends _PrimitiveTypes RealmObjectBase.registerFactory(PrimitiveTypes._); register(_toEJson, _fromEJson); return const SchemaObject( - ObjectType.realmObject, PrimitiveTypes, 'PrimitiveTypes', [ - SchemaProperty('stringProp', RealmPropertyType.string), - SchemaProperty('boolProp', RealmPropertyType.bool), - SchemaProperty('dateProp', RealmPropertyType.timestamp), - SchemaProperty('doubleProp', RealmPropertyType.double), - SchemaProperty('objectIdProp', RealmPropertyType.objectid), - ]); + ObjectType.realmObject, + PrimitiveTypes, + 'PrimitiveTypes', + [ + SchemaProperty('stringProp', RealmPropertyType.string), + SchemaProperty('boolProp', RealmPropertyType.bool), + SchemaProperty('dateProp', RealmPropertyType.timestamp), + SchemaProperty('doubleProp', RealmPropertyType.double), + SchemaProperty('objectIdProp', RealmPropertyType.objectid), + ], + ); }(); @override diff --git a/packages/realm_generator/test/good_test_data/another_mapto.expected_multi b/packages/realm_generator/test/good_test_data/another_mapto.expected_multi index beea0ce85..52987daa7 100644 --- a/packages/realm_generator/test/good_test_data/another_mapto.expected_multi +++ b/packages/realm_generator/test/good_test_data/another_mapto.expected_multi @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'another_mapto.dart'; @@ -10,13 +11,13 @@ part of 'another_mapto.dart'; // ignore_for_file: type=lint class MappedToo extends _MappedToo with RealmEntity, RealmObjectBase, RealmObject { - MappedToo({ - Original? singleLink, - Iterable listLink = const [], - }) { + MappedToo({Original? singleLink, Iterable listLink = const []}) { RealmObjectBase.set(this, 'singleLink', singleLink); RealmObjectBase.set>( - this, 'listLink', RealmList(listLink)); + this, + 'listLink', + RealmList(listLink), + ); } MappedToo._(); @@ -66,12 +67,24 @@ class MappedToo extends _MappedToo RealmObjectBase.registerFactory(MappedToo._); register(_toEJson, _fromEJson); return const SchemaObject( - ObjectType.realmObject, MappedToo, 'this is also mapped', [ - SchemaProperty('singleLink', RealmPropertyType.object, - optional: true, linkTarget: 'another type'), - SchemaProperty('listLink', RealmPropertyType.object, - linkTarget: 'another type', collectionType: RealmCollectionType.list), - ]); + ObjectType.realmObject, + MappedToo, + 'this is also mapped', + [ + SchemaProperty( + 'singleLink', + RealmPropertyType.object, + optional: true, + linkTarget: 'another type', + ), + SchemaProperty( + 'listLink', + RealmPropertyType.object, + linkTarget: 'another type', + collectionType: RealmCollectionType.list, + ), + ], + ); }(); @override diff --git a/packages/realm_generator/test/good_test_data/binary_type.expected b/packages/realm_generator/test/good_test_data/binary_type.expected index 8cd85f588..300cbb7c9 100644 --- a/packages/realm_generator/test/good_test_data/binary_type.expected +++ b/packages/realm_generator/test/good_test_data/binary_type.expected @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'binary_type.dart'; @@ -9,10 +10,7 @@ part of 'binary_type.dart'; // coverage:ignore-file // ignore_for_file: type=lint class Foo extends _Foo with RealmEntity, RealmObjectBase, RealmObject { - Foo( - Uint8List requiredBinaryProp, { - Uint8List? nullableBinaryProp, - }) { + Foo(Uint8List requiredBinaryProp, {Uint8List? nullableBinaryProp}) { RealmObjectBase.set(this, 'requiredBinaryProp', requiredBinaryProp); RealmObjectBase.set(this, 'nullableBinaryProp', nullableBinaryProp); } @@ -55,10 +53,7 @@ class Foo extends _Foo with RealmEntity, RealmObjectBase, RealmObject { static Foo _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); return switch (ejson) { - { - 'requiredBinaryProp': EJsonValue requiredBinaryProp, - } => - Foo( + {'requiredBinaryProp': EJsonValue requiredBinaryProp} => Foo( fromEJson(requiredBinaryProp), nullableBinaryProp: fromEJson(ejson['nullableBinaryProp']), ), @@ -71,8 +66,11 @@ class Foo extends _Foo with RealmEntity, RealmObjectBase, RealmObject { register(_toEJson, _fromEJson); return const SchemaObject(ObjectType.realmObject, Foo, 'Foo', [ SchemaProperty('requiredBinaryProp', RealmPropertyType.binary), - SchemaProperty('nullableBinaryProp', RealmPropertyType.binary, - optional: true), + SchemaProperty( + 'nullableBinaryProp', + RealmPropertyType.binary, + optional: true, + ), ]); }(); diff --git a/packages/realm_generator/test/good_test_data/const_initializer.expected b/packages/realm_generator/test/good_test_data/const_initializer.expected index ce5577114..b8f7024d7 100644 --- a/packages/realm_generator/test/good_test_data/const_initializer.expected +++ b/packages/realm_generator/test/good_test_data/const_initializer.expected @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'const_initializer.dart'; @@ -61,17 +62,35 @@ class ConstInitializer extends _ConstInitializer RealmObjectBase.set(this, 'fooEnv', fooEnv); RealmObjectBase.set(this, 'fooLit', fooLit); RealmObjectBase.set>( - this, 'constEmptyList', RealmList(constEmptyList)); + this, + 'constEmptyList', + RealmList(constEmptyList), + ); RealmObjectBase.set>( - this, 'constEmptyMap', RealmMap(constEmptyMap)); + this, + 'constEmptyMap', + RealmMap(constEmptyMap), + ); RealmObjectBase.set>( - this, 'constEmptySet', RealmSet(constEmptySet)); + this, + 'constEmptySet', + RealmSet(constEmptySet), + ); RealmObjectBase.set>( - this, 'emptyList', RealmList(emptyList)); + this, + 'emptyList', + RealmList(emptyList), + ); RealmObjectBase.set>( - this, 'emptyMao', RealmMap(emptyMao)); + this, + 'emptyMao', + RealmMap(emptyMao), + ); RealmObjectBase.set>( - this, 'emptySet', RealmSet(emptySet)); + this, + 'emptySet', + RealmSet(emptySet), + ); } ConstInitializer._(); @@ -188,8 +207,9 @@ class ConstInitializer extends _ConstInitializer RealmObjectBase.getChanges(this); @override - Stream> changesFor( - [List? keyPaths]) => + Stream> changesFor([ + List? keyPaths, + ]) => RealmObjectBase.getChangesFor(this, keyPaths); @override @@ -225,21 +245,29 @@ class ConstInitializer extends _ConstInitializer return ConstInitializer( zero: fromEJson(ejson['zero'], defaultValue: 0), minusOne: fromEJson(ejson['minusOne'], defaultValue: -1), - fooOrOne: fromEJson(ejson['fooOrOne'], - defaultValue: const int.fromEnvironment('FOO', defaultValue: 1)), + fooOrOne: fromEJson( + ejson['fooOrOne'], + defaultValue: const int.fromEnvironment('FOO', defaultValue: 1), + ), parenthesis: fromEJson(ejson['parenthesis'], defaultValue: (1)), minusMinusOne: fromEJson(ejson['minusMinusOne'], defaultValue: -(-1)), add: fromEJson(ejson['add'], defaultValue: 1 + 1), identifier: fromEJson(ejson['identifier'], defaultValue: myConst), infinity: fromEJson(ejson['infinity'], defaultValue: double.infinity), nan: fromEJson(ejson['nan'], defaultValue: double.nan), - negativeInfinity: fromEJson(ejson['negativeInfinity'], - defaultValue: double.negativeInfinity), - fooEnv: fromEJson(ejson['fooEnv'], - defaultValue: const String.fromEnvironment('FOO')), + negativeInfinity: fromEJson( + ejson['negativeInfinity'], + defaultValue: double.negativeInfinity, + ), + fooEnv: fromEJson( + ejson['fooEnv'], + defaultValue: const String.fromEnvironment('FOO'), + ), fooLit: fromEJson(ejson['fooLit'], defaultValue: 'foo'), - constEmptyList: - fromEJson(ejson['constEmptyList'], defaultValue: const []), + constEmptyList: fromEJson( + ejson['constEmptyList'], + defaultValue: const [], + ), constEmptyMap: fromEJson(ejson['constEmptyMap'], defaultValue: const {}), constEmptySet: fromEJson(ejson['constEmptySet'], defaultValue: const {}), emptyList: fromEJson(ejson['emptyList'], defaultValue: const []), @@ -252,32 +280,54 @@ class ConstInitializer extends _ConstInitializer RealmObjectBase.registerFactory(ConstInitializer._); register(_toEJson, _fromEJson); return const SchemaObject( - ObjectType.realmObject, ConstInitializer, 'ConstInitializer', [ - SchemaProperty('zero', RealmPropertyType.int), - SchemaProperty('minusOne', RealmPropertyType.int), - SchemaProperty('fooOrOne', RealmPropertyType.int), - SchemaProperty('parenthesis', RealmPropertyType.int), - SchemaProperty('minusMinusOne', RealmPropertyType.int), - SchemaProperty('add', RealmPropertyType.int), - SchemaProperty('identifier', RealmPropertyType.int), - SchemaProperty('infinity', RealmPropertyType.double), - SchemaProperty('nan', RealmPropertyType.double), - SchemaProperty('negativeInfinity', RealmPropertyType.double), - SchemaProperty('fooEnv', RealmPropertyType.string), - SchemaProperty('fooLit', RealmPropertyType.string), - SchemaProperty('constEmptyList', RealmPropertyType.int, - collectionType: RealmCollectionType.list), - SchemaProperty('constEmptyMap', RealmPropertyType.int, - collectionType: RealmCollectionType.map), - SchemaProperty('constEmptySet', RealmPropertyType.int, - collectionType: RealmCollectionType.set), - SchemaProperty('emptyList', RealmPropertyType.int, - collectionType: RealmCollectionType.list), - SchemaProperty('emptyMao', RealmPropertyType.int, - collectionType: RealmCollectionType.map), - SchemaProperty('emptySet', RealmPropertyType.int, - collectionType: RealmCollectionType.set), - ]); + ObjectType.realmObject, + ConstInitializer, + 'ConstInitializer', + [ + SchemaProperty('zero', RealmPropertyType.int), + SchemaProperty('minusOne', RealmPropertyType.int), + SchemaProperty('fooOrOne', RealmPropertyType.int), + SchemaProperty('parenthesis', RealmPropertyType.int), + SchemaProperty('minusMinusOne', RealmPropertyType.int), + SchemaProperty('add', RealmPropertyType.int), + SchemaProperty('identifier', RealmPropertyType.int), + SchemaProperty('infinity', RealmPropertyType.double), + SchemaProperty('nan', RealmPropertyType.double), + SchemaProperty('negativeInfinity', RealmPropertyType.double), + SchemaProperty('fooEnv', RealmPropertyType.string), + SchemaProperty('fooLit', RealmPropertyType.string), + SchemaProperty( + 'constEmptyList', + RealmPropertyType.int, + collectionType: RealmCollectionType.list, + ), + SchemaProperty( + 'constEmptyMap', + RealmPropertyType.int, + collectionType: RealmCollectionType.map, + ), + SchemaProperty( + 'constEmptySet', + RealmPropertyType.int, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'emptyList', + RealmPropertyType.int, + collectionType: RealmCollectionType.list, + ), + SchemaProperty( + 'emptyMao', + RealmPropertyType.int, + collectionType: RealmCollectionType.map, + ), + SchemaProperty( + 'emptySet', + RealmPropertyType.int, + collectionType: RealmCollectionType.set, + ), + ], + ); }(); @override diff --git a/packages/realm_generator/test/good_test_data/embedded_annotations.expected b/packages/realm_generator/test/good_test_data/embedded_annotations.expected index 6005b8283..eda31f5c7 100644 --- a/packages/realm_generator/test/good_test_data/embedded_annotations.expected +++ b/packages/realm_generator/test/good_test_data/embedded_annotations.expected @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'embedded_annotations.dart'; @@ -9,13 +10,13 @@ part of 'embedded_annotations.dart'; // coverage:ignore-file // ignore_for_file: type=lint class Parent extends _Parent with RealmEntity, RealmObjectBase, RealmObject { - Parent({ - Child1? child, - Iterable children = const [], - }) { + Parent({Child1? child, Iterable children = const []}) { RealmObjectBase.set(this, 'single child', child); RealmObjectBase.set>( - this, 'CHILDREN', RealmList(children)); + this, + 'CHILDREN', + RealmList(children), + ); } Parent._(); @@ -65,12 +66,20 @@ class Parent extends _Parent with RealmEntity, RealmObjectBase, RealmObject { RealmObjectBase.registerFactory(Parent._); register(_toEJson, _fromEJson); return const SchemaObject(ObjectType.realmObject, Parent, 'Parent', [ - SchemaProperty('child', RealmPropertyType.object, - mapTo: 'single child', optional: true, linkTarget: 'MySuperChild'), - SchemaProperty('children', RealmPropertyType.object, - mapTo: 'CHILDREN', - linkTarget: 'MySuperChild', - collectionType: RealmCollectionType.list), + SchemaProperty( + 'child', + RealmPropertyType.object, + mapTo: 'single child', + optional: true, + linkTarget: 'MySuperChild', + ), + SchemaProperty( + 'children', + RealmPropertyType.object, + mapTo: 'CHILDREN', + linkTarget: 'MySuperChild', + collectionType: RealmCollectionType.list, + ), ]); }(); @@ -79,11 +88,7 @@ class Parent extends _Parent with RealmEntity, RealmObjectBase, RealmObject { } class Child1 extends _Child1 with RealmEntity, RealmObjectBase, EmbeddedObject { - Child1( - String value, - String indexedString, { - Parent? linkToParent, - }) { + Child1(String value, String indexedString, {Parent? linkToParent}) { RealmObjectBase.set(this, '_value', value); RealmObjectBase.set(this, '_parent', linkToParent); RealmObjectBase.set(this, 'indexedString', indexedString); @@ -133,10 +138,7 @@ class Child1 extends _Child1 with RealmEntity, RealmObjectBase, EmbeddedObject { static Child1 _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); return switch (ejson) { - { - '_value': EJsonValue value, - 'indexedString': EJsonValue indexedString, - } => + {'_value': EJsonValue value, 'indexedString': EJsonValue indexedString} => Child1( fromEJson(value), fromEJson(indexedString), @@ -149,13 +151,26 @@ class Child1 extends _Child1 with RealmEntity, RealmObjectBase, EmbeddedObject { static final schema = () { RealmObjectBase.registerFactory(Child1._); register(_toEJson, _fromEJson); - return const SchemaObject(ObjectType.embeddedObject, Child1, 'MySuperChild', [ - SchemaProperty('value', RealmPropertyType.string, mapTo: '_value'), - SchemaProperty('linkToParent', RealmPropertyType.object, - mapTo: '_parent', optional: true, linkTarget: 'Parent'), - SchemaProperty('indexedString', RealmPropertyType.string, - indexType: RealmIndexType.regular), - ]); + return const SchemaObject( + ObjectType.embeddedObject, + Child1, + 'MySuperChild', + [ + SchemaProperty('value', RealmPropertyType.string, mapTo: '_value'), + SchemaProperty( + 'linkToParent', + RealmPropertyType.object, + mapTo: '_parent', + optional: true, + linkTarget: 'Parent', + ), + SchemaProperty( + 'indexedString', + RealmPropertyType.string, + indexType: RealmIndexType.regular, + ), + ], + ); }(); @override diff --git a/packages/realm_generator/test/good_test_data/embedded_objects.expected b/packages/realm_generator/test/good_test_data/embedded_objects.expected index a21025b54..9c56750f9 100644 --- a/packages/realm_generator/test/good_test_data/embedded_objects.expected +++ b/packages/realm_generator/test/good_test_data/embedded_objects.expected @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'embedded_objects.dart'; @@ -9,13 +10,13 @@ part of 'embedded_objects.dart'; // coverage:ignore-file // ignore_for_file: type=lint class Parent extends _Parent with RealmEntity, RealmObjectBase, RealmObject { - Parent({ - Child1? child, - Iterable children = const [], - }) { + Parent({Child1? child, Iterable children = const []}) { RealmObjectBase.set(this, 'child', child); RealmObjectBase.set>( - this, 'children', RealmList(children)); + this, + 'children', + RealmList(children), + ); } Parent._(); @@ -64,10 +65,18 @@ class Parent extends _Parent with RealmEntity, RealmObjectBase, RealmObject { RealmObjectBase.registerFactory(Parent._); register(_toEJson, _fromEJson); return const SchemaObject(ObjectType.realmObject, Parent, 'Parent', [ - SchemaProperty('child', RealmPropertyType.object, - optional: true, linkTarget: 'Child1'), - SchemaProperty('children', RealmPropertyType.object, - linkTarget: 'Child1', collectionType: RealmCollectionType.list), + SchemaProperty( + 'child', + RealmPropertyType.object, + optional: true, + linkTarget: 'Child1', + ), + SchemaProperty( + 'children', + RealmPropertyType.object, + linkTarget: 'Child1', + collectionType: RealmCollectionType.list, + ), ]); }(); @@ -85,7 +94,10 @@ class Child1 extends _Child1 with RealmEntity, RealmObjectBase, EmbeddedObject { RealmObjectBase.set(this, 'value', value); RealmObjectBase.set(this, 'child', child); RealmObjectBase.set>( - this, 'children', RealmList(children)); + this, + 'children', + RealmList(children), + ); RealmObjectBase.set(this, 'linkToParent', linkToParent); } @@ -140,10 +152,7 @@ class Child1 extends _Child1 with RealmEntity, RealmObjectBase, EmbeddedObject { static Child1 _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); return switch (ejson) { - { - 'value': EJsonValue value, - } => - Child1( + {'value': EJsonValue value} => Child1( fromEJson(value), child: fromEJson(ejson['child']), children: fromEJson(ejson['children']), @@ -158,12 +167,24 @@ class Child1 extends _Child1 with RealmEntity, RealmObjectBase, EmbeddedObject { register(_toEJson, _fromEJson); return const SchemaObject(ObjectType.embeddedObject, Child1, 'Child1', [ SchemaProperty('value', RealmPropertyType.string), - SchemaProperty('child', RealmPropertyType.object, - optional: true, linkTarget: 'Child2'), - SchemaProperty('children', RealmPropertyType.object, - linkTarget: 'Child2', collectionType: RealmCollectionType.list), - SchemaProperty('linkToParent', RealmPropertyType.object, - optional: true, linkTarget: 'Parent'), + SchemaProperty( + 'child', + RealmPropertyType.object, + optional: true, + linkTarget: 'Child2', + ), + SchemaProperty( + 'children', + RealmPropertyType.object, + linkTarget: 'Child2', + collectionType: RealmCollectionType.list, + ), + SchemaProperty( + 'linkToParent', + RealmPropertyType.object, + optional: true, + linkTarget: 'Parent', + ), ]); }(); @@ -371,19 +392,37 @@ class Child2 extends _Child2 with RealmEntity, RealmObjectBase, EmbeddedObject { SchemaProperty('dateProp', RealmPropertyType.timestamp), SchemaProperty('objectIdProp', RealmPropertyType.objectid), SchemaProperty('uuidProp', RealmPropertyType.uuid), - SchemaProperty('nullableBoolProp', RealmPropertyType.bool, - optional: true), + SchemaProperty( + 'nullableBoolProp', + RealmPropertyType.bool, + optional: true, + ), SchemaProperty('nullableIntProp', RealmPropertyType.int, optional: true), - SchemaProperty('nullableDoubleProp', RealmPropertyType.double, - optional: true), - SchemaProperty('nullableStringProp', RealmPropertyType.string, - optional: true), - SchemaProperty('nullableDateProp', RealmPropertyType.timestamp, - optional: true), - SchemaProperty('nullableObjectIdProp', RealmPropertyType.objectid, - optional: true), - SchemaProperty('nullableUuidProp', RealmPropertyType.uuid, - optional: true), + SchemaProperty( + 'nullableDoubleProp', + RealmPropertyType.double, + optional: true, + ), + SchemaProperty( + 'nullableStringProp', + RealmPropertyType.string, + optional: true, + ), + SchemaProperty( + 'nullableDateProp', + RealmPropertyType.timestamp, + optional: true, + ), + SchemaProperty( + 'nullableObjectIdProp', + RealmPropertyType.objectid, + optional: true, + ), + SchemaProperty( + 'nullableUuidProp', + RealmPropertyType.uuid, + optional: true, + ), ]); }(); diff --git a/packages/realm_generator/test/good_test_data/indexable_types.expected b/packages/realm_generator/test/good_test_data/indexable_types.expected index e71ae6e97..255077a99 100644 --- a/packages/realm_generator/test/good_test_data/indexable_types.expected +++ b/packages/realm_generator/test/good_test_data/indexable_types.expected @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'indexable_types.dart'; @@ -224,38 +225,94 @@ class Indexable extends _Indexable RealmObjectBase.registerFactory(Indexable._); register(_toEJson, _fromEJson); return const SchemaObject(ObjectType.realmObject, Indexable, 'Indexable', [ - SchemaProperty('aBool', RealmPropertyType.bool, - indexType: RealmIndexType.regular), - SchemaProperty('aNullableBool', RealmPropertyType.bool, - optional: true, indexType: RealmIndexType.regular), - SchemaProperty('anInt', RealmPropertyType.int, - indexType: RealmIndexType.regular), - SchemaProperty('aNullableInt', RealmPropertyType.int, - optional: true, indexType: RealmIndexType.regular), - SchemaProperty('aString', RealmPropertyType.string, - indexType: RealmIndexType.regular), - SchemaProperty('aNullableString', RealmPropertyType.string, - optional: true, indexType: RealmIndexType.regular), - SchemaProperty('anObjectId', RealmPropertyType.objectid, - indexType: RealmIndexType.regular), - SchemaProperty('aNullableObjectId', RealmPropertyType.objectid, - optional: true, indexType: RealmIndexType.regular), - SchemaProperty('anUuid', RealmPropertyType.uuid, - indexType: RealmIndexType.regular), - SchemaProperty('aNullableUuid', RealmPropertyType.uuid, - optional: true, indexType: RealmIndexType.regular), - SchemaProperty('aDateTime', RealmPropertyType.timestamp, - indexType: RealmIndexType.regular), - SchemaProperty('aNullableDateTime', RealmPropertyType.timestamp, - optional: true, indexType: RealmIndexType.regular), - SchemaProperty('aRealmValue', RealmPropertyType.mixed, - optional: true, indexType: RealmIndexType.regular), - SchemaProperty('generalStringIndex', RealmPropertyType.string, - indexType: RealmIndexType.regular), - SchemaProperty('ftsStringValue', RealmPropertyType.string, - indexType: RealmIndexType.fullText), - SchemaProperty('nullableFtsStringValue', RealmPropertyType.string, - optional: true, indexType: RealmIndexType.fullText), + SchemaProperty( + 'aBool', + RealmPropertyType.bool, + indexType: RealmIndexType.regular, + ), + SchemaProperty( + 'aNullableBool', + RealmPropertyType.bool, + optional: true, + indexType: RealmIndexType.regular, + ), + SchemaProperty( + 'anInt', + RealmPropertyType.int, + indexType: RealmIndexType.regular, + ), + SchemaProperty( + 'aNullableInt', + RealmPropertyType.int, + optional: true, + indexType: RealmIndexType.regular, + ), + SchemaProperty( + 'aString', + RealmPropertyType.string, + indexType: RealmIndexType.regular, + ), + SchemaProperty( + 'aNullableString', + RealmPropertyType.string, + optional: true, + indexType: RealmIndexType.regular, + ), + SchemaProperty( + 'anObjectId', + RealmPropertyType.objectid, + indexType: RealmIndexType.regular, + ), + SchemaProperty( + 'aNullableObjectId', + RealmPropertyType.objectid, + optional: true, + indexType: RealmIndexType.regular, + ), + SchemaProperty( + 'anUuid', + RealmPropertyType.uuid, + indexType: RealmIndexType.regular, + ), + SchemaProperty( + 'aNullableUuid', + RealmPropertyType.uuid, + optional: true, + indexType: RealmIndexType.regular, + ), + SchemaProperty( + 'aDateTime', + RealmPropertyType.timestamp, + indexType: RealmIndexType.regular, + ), + SchemaProperty( + 'aNullableDateTime', + RealmPropertyType.timestamp, + optional: true, + indexType: RealmIndexType.regular, + ), + SchemaProperty( + 'aRealmValue', + RealmPropertyType.mixed, + optional: true, + indexType: RealmIndexType.regular, + ), + SchemaProperty( + 'generalStringIndex', + RealmPropertyType.string, + indexType: RealmIndexType.regular, + ), + SchemaProperty( + 'ftsStringValue', + RealmPropertyType.string, + indexType: RealmIndexType.fullText, + ), + SchemaProperty( + 'nullableFtsStringValue', + RealmPropertyType.string, + optional: true, + indexType: RealmIndexType.fullText, + ), ]); }(); diff --git a/packages/realm_generator/test/good_test_data/list_initialization.expected b/packages/realm_generator/test/good_test_data/list_initialization.expected index 1fa56df7e..324b1da81 100644 --- a/packages/realm_generator/test/good_test_data/list_initialization.expected +++ b/packages/realm_generator/test/good_test_data/list_initialization.expected @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'list_initialization.dart'; @@ -22,23 +23,47 @@ class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { Map initMapConst = const {}, }) { RealmObjectBase.set>( - this, 'children', RealmList(children)); + this, + 'children', + RealmList(children), + ); RealmObjectBase.set>( - this, 'initList', RealmList(initList)); + this, + 'initList', + RealmList(initList), + ); RealmObjectBase.set>( - this, 'initListWithType', RealmList(initListWithType)); + this, + 'initListWithType', + RealmList(initListWithType), + ); RealmObjectBase.set>( - this, 'initListConst', RealmList(initListConst)); + this, + 'initListConst', + RealmList(initListConst), + ); RealmObjectBase.set>(this, 'initSet', RealmSet(initSet)); RealmObjectBase.set>( - this, 'initSetWithType', RealmSet(initSetWithType)); + this, + 'initSetWithType', + RealmSet(initSetWithType), + ); RealmObjectBase.set>( - this, 'initSetConst', RealmSet(initSetConst)); + this, + 'initSetConst', + RealmSet(initSetConst), + ); RealmObjectBase.set>(this, 'initMap', RealmMap(initMap)); RealmObjectBase.set>( - this, 'initMapWithType', RealmMap(initMapWithType)); + this, + 'initMapWithType', + RealmMap(initMapWithType), + ); RealmObjectBase.set>( - this, 'initMapConst', RealmMap(initMapConst)); + this, + 'initMapConst', + RealmMap(initMapConst), + ); } Person._(); @@ -145,16 +170,22 @@ class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { return Person( children: fromEJson(ejson['children']), initList: fromEJson(ejson['initList'], defaultValue: const []), - initListWithType: - fromEJson(ejson['initListWithType'], defaultValue: const []), + initListWithType: fromEJson( + ejson['initListWithType'], + defaultValue: const [], + ), initListConst: fromEJson(ejson['initListConst'], defaultValue: const []), initSet: fromEJson(ejson['initSet'], defaultValue: const {}), - initSetWithType: - fromEJson(ejson['initSetWithType'], defaultValue: const {}), + initSetWithType: fromEJson( + ejson['initSetWithType'], + defaultValue: const {}, + ), initSetConst: fromEJson(ejson['initSetConst'], defaultValue: const {}), initMap: fromEJson(ejson['initMap'], defaultValue: const {}), - initMapWithType: - fromEJson(ejson['initMapWithType'], defaultValue: const {}), + initMapWithType: fromEJson( + ejson['initMapWithType'], + defaultValue: const {}, + ), initMapConst: fromEJson(ejson['initMapConst'], defaultValue: const {}), ); } @@ -163,26 +194,57 @@ class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { RealmObjectBase.registerFactory(Person._); register(_toEJson, _fromEJson); return const SchemaObject(ObjectType.realmObject, Person, 'Person', [ - SchemaProperty('children', RealmPropertyType.object, - linkTarget: 'Person', collectionType: RealmCollectionType.list), - SchemaProperty('initList', RealmPropertyType.int, - collectionType: RealmCollectionType.list), - SchemaProperty('initListWithType', RealmPropertyType.int, - collectionType: RealmCollectionType.list), - SchemaProperty('initListConst', RealmPropertyType.int, - collectionType: RealmCollectionType.list), - SchemaProperty('initSet', RealmPropertyType.int, - collectionType: RealmCollectionType.set), - SchemaProperty('initSetWithType', RealmPropertyType.int, - collectionType: RealmCollectionType.set), - SchemaProperty('initSetConst', RealmPropertyType.int, - collectionType: RealmCollectionType.set), - SchemaProperty('initMap', RealmPropertyType.int, - collectionType: RealmCollectionType.map), - SchemaProperty('initMapWithType', RealmPropertyType.int, - collectionType: RealmCollectionType.map), - SchemaProperty('initMapConst', RealmPropertyType.int, - collectionType: RealmCollectionType.map), + SchemaProperty( + 'children', + RealmPropertyType.object, + linkTarget: 'Person', + collectionType: RealmCollectionType.list, + ), + SchemaProperty( + 'initList', + RealmPropertyType.int, + collectionType: RealmCollectionType.list, + ), + SchemaProperty( + 'initListWithType', + RealmPropertyType.int, + collectionType: RealmCollectionType.list, + ), + SchemaProperty( + 'initListConst', + RealmPropertyType.int, + collectionType: RealmCollectionType.list, + ), + SchemaProperty( + 'initSet', + RealmPropertyType.int, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'initSetWithType', + RealmPropertyType.int, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'initSetConst', + RealmPropertyType.int, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'initMap', + RealmPropertyType.int, + collectionType: RealmCollectionType.map, + ), + SchemaProperty( + 'initMapWithType', + RealmPropertyType.int, + collectionType: RealmCollectionType.map, + ), + SchemaProperty( + 'initMapConst', + RealmPropertyType.int, + collectionType: RealmCollectionType.map, + ), ]); }(); diff --git a/packages/realm_generator/test/good_test_data/map.expected b/packages/realm_generator/test/good_test_data/map.expected index b1c81536a..5fe9bbb6b 100644 --- a/packages/realm_generator/test/good_test_data/map.expected +++ b/packages/realm_generator/test/good_test_data/map.expected @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'map.dart'; @@ -24,23 +25,47 @@ class LotsOfMaps extends _LotsOfMaps Map uuids = const {}, }) { RealmObjectBase.set>( - this, 'persons', RealmMap(persons)); + this, + 'persons', + RealmMap(persons), + ); RealmObjectBase.set>(this, 'bools', RealmMap(bools)); RealmObjectBase.set>( - this, 'dateTimes', RealmMap(dateTimes)); + this, + 'dateTimes', + RealmMap(dateTimes), + ); RealmObjectBase.set>( - this, 'decimals', RealmMap(decimals)); + this, + 'decimals', + RealmMap(decimals), + ); RealmObjectBase.set>( - this, 'doubles', RealmMap(doubles)); + this, + 'doubles', + RealmMap(doubles), + ); RealmObjectBase.set>(this, 'ints', RealmMap(ints)); RealmObjectBase.set>( - this, 'objectIds', RealmMap(objectIds)); + this, + 'objectIds', + RealmMap(objectIds), + ); RealmObjectBase.set>( - this, 'any', RealmMap(any)); + this, + 'any', + RealmMap(any), + ); RealmObjectBase.set>( - this, 'strings', RealmMap(strings)); + this, + 'strings', + RealmMap(strings), + ); RealmObjectBase.set>( - this, 'binary', RealmMap(binary)); + this, + 'binary', + RealmMap(binary), + ); RealmObjectBase.set>(this, 'uuids', RealmMap(uuids)); } @@ -168,32 +193,71 @@ class LotsOfMaps extends _LotsOfMaps static final schema = () { RealmObjectBase.registerFactory(LotsOfMaps._); register(_toEJson, _fromEJson); - return const SchemaObject(ObjectType.realmObject, LotsOfMaps, 'LotsOfMaps', [ - SchemaProperty('persons', RealmPropertyType.object, + return const SchemaObject( + ObjectType.realmObject, + LotsOfMaps, + 'LotsOfMaps', + [ + SchemaProperty( + 'persons', + RealmPropertyType.object, optional: true, linkTarget: 'Person', - collectionType: RealmCollectionType.map), - SchemaProperty('bools', RealmPropertyType.bool, - collectionType: RealmCollectionType.map), - SchemaProperty('dateTimes', RealmPropertyType.timestamp, - collectionType: RealmCollectionType.map), - SchemaProperty('decimals', RealmPropertyType.decimal128, - collectionType: RealmCollectionType.map), - SchemaProperty('doubles', RealmPropertyType.double, - collectionType: RealmCollectionType.map), - SchemaProperty('ints', RealmPropertyType.int, - collectionType: RealmCollectionType.map), - SchemaProperty('objectIds', RealmPropertyType.objectid, - collectionType: RealmCollectionType.map), - SchemaProperty('any', RealmPropertyType.mixed, - optional: true, collectionType: RealmCollectionType.map), - SchemaProperty('strings', RealmPropertyType.string, - collectionType: RealmCollectionType.map), - SchemaProperty('binary', RealmPropertyType.binary, - collectionType: RealmCollectionType.map), - SchemaProperty('uuids', RealmPropertyType.uuid, - collectionType: RealmCollectionType.map), - ]); + collectionType: RealmCollectionType.map, + ), + SchemaProperty( + 'bools', + RealmPropertyType.bool, + collectionType: RealmCollectionType.map, + ), + SchemaProperty( + 'dateTimes', + RealmPropertyType.timestamp, + collectionType: RealmCollectionType.map, + ), + SchemaProperty( + 'decimals', + RealmPropertyType.decimal128, + collectionType: RealmCollectionType.map, + ), + SchemaProperty( + 'doubles', + RealmPropertyType.double, + collectionType: RealmCollectionType.map, + ), + SchemaProperty( + 'ints', + RealmPropertyType.int, + collectionType: RealmCollectionType.map, + ), + SchemaProperty( + 'objectIds', + RealmPropertyType.objectid, + collectionType: RealmCollectionType.map, + ), + SchemaProperty( + 'any', + RealmPropertyType.mixed, + optional: true, + collectionType: RealmCollectionType.map, + ), + SchemaProperty( + 'strings', + RealmPropertyType.string, + collectionType: RealmCollectionType.map, + ), + SchemaProperty( + 'binary', + RealmPropertyType.binary, + collectionType: RealmCollectionType.map, + ), + SchemaProperty( + 'uuids', + RealmPropertyType.uuid, + collectionType: RealmCollectionType.map, + ), + ], + ); }(); @override @@ -201,9 +265,7 @@ class LotsOfMaps extends _LotsOfMaps } class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { - Person( - String name, - ) { + Person(String name) { RealmObjectBase.set(this, 'name', name); } @@ -226,21 +288,14 @@ class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { Person freeze() => RealmObjectBase.freezeObject(this); EJsonValue toEJson() { - return { - 'name': name.toEJson(), - }; + return {'name': name.toEJson()}; } static EJsonValue _toEJson(Person value) => value.toEJson(); static Person _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); return switch (ejson) { - { - 'name': EJsonValue name, - } => - Person( - fromEJson(name), - ), + {'name': EJsonValue name} => Person(fromEJson(name)), _ => raiseInvalidEJson(ejson), }; } diff --git a/packages/realm_generator/test/good_test_data/mapto.expected b/packages/realm_generator/test/good_test_data/mapto.expected index e69afc9da..497b3d708 100644 --- a/packages/realm_generator/test/good_test_data/mapto.expected +++ b/packages/realm_generator/test/good_test_data/mapto.expected @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'mapto.dart'; @@ -25,7 +26,10 @@ class Original extends $Original RealmObjectBase.set(this, 'remapped primitive', primitiveProperty); RealmObjectBase.set(this, 'remapped object', objectProperty); RealmObjectBase.set>( - this, 'remapped list', RealmList(listProperty)); + this, + 'remapped list', + RealmList(listProperty), + ); } Original._(); @@ -75,8 +79,10 @@ class Original extends $Original static Original _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); return Original( - primitiveProperty: - fromEJson(ejson['remapped primitive'], defaultValue: 0), + primitiveProperty: fromEJson( + ejson['remapped primitive'], + defaultValue: 0, + ), objectProperty: fromEJson(ejson['remapped object']), listProperty: fromEJson(ejson['remapped list']), ); @@ -85,16 +91,32 @@ class Original extends $Original static final schema = () { RealmObjectBase.registerFactory(Original._); register(_toEJson, _fromEJson); - return const SchemaObject(ObjectType.realmObject, Original, 'another type', [ - SchemaProperty('primitiveProperty', RealmPropertyType.int, - mapTo: 'remapped primitive'), - SchemaProperty('objectProperty', RealmPropertyType.object, - mapTo: 'remapped object', optional: true, linkTarget: 'another type'), - SchemaProperty('listProperty', RealmPropertyType.object, + return const SchemaObject( + ObjectType.realmObject, + Original, + 'another type', + [ + SchemaProperty( + 'primitiveProperty', + RealmPropertyType.int, + mapTo: 'remapped primitive', + ), + SchemaProperty( + 'objectProperty', + RealmPropertyType.object, + mapTo: 'remapped object', + optional: true, + linkTarget: 'another type', + ), + SchemaProperty( + 'listProperty', + RealmPropertyType.object, mapTo: 'remapped list', linkTarget: 'another type', - collectionType: RealmCollectionType.list), - ]); + collectionType: RealmCollectionType.list, + ), + ], + ); }(); @override diff --git a/packages/realm_generator/test/good_test_data/optional_argument.expected b/packages/realm_generator/test/good_test_data/optional_argument.expected index 073d678dc..6e96bdede 100644 --- a/packages/realm_generator/test/good_test_data/optional_argument.expected +++ b/packages/realm_generator/test/good_test_data/optional_argument.expected @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'optional_argument.dart'; @@ -9,9 +10,7 @@ part of 'optional_argument.dart'; // coverage:ignore-file // ignore_for_file: type=lint class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { - Person({ - Person? spouse, - }) { + Person({Person? spouse}) { RealmObjectBase.set(this, 'spouse', spouse); } @@ -35,25 +34,25 @@ class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { Person freeze() => RealmObjectBase.freezeObject(this); EJsonValue toEJson() { - return { - 'spouse': spouse.toEJson(), - }; + return {'spouse': spouse.toEJson()}; } static EJsonValue _toEJson(Person value) => value.toEJson(); static Person _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); - return Person( - spouse: fromEJson(ejson['spouse']), - ); + return Person(spouse: fromEJson(ejson['spouse'])); } static final schema = () { RealmObjectBase.registerFactory(Person._); register(_toEJson, _fromEJson); return const SchemaObject(ObjectType.realmObject, Person, 'Person', [ - SchemaProperty('spouse', RealmPropertyType.object, - optional: true, linkTarget: 'Person'), + SchemaProperty( + 'spouse', + RealmPropertyType.object, + optional: true, + linkTarget: 'Person', + ), ]); }(); diff --git a/packages/realm_generator/test/good_test_data/pinhole.expected b/packages/realm_generator/test/good_test_data/pinhole.expected index 94fe8189f..6b4941f7e 100644 --- a/packages/realm_generator/test/good_test_data/pinhole.expected +++ b/packages/realm_generator/test/good_test_data/pinhole.expected @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'pinhole.dart'; @@ -11,13 +12,9 @@ part of 'pinhole.dart'; class Foo extends _Foo with RealmEntity, RealmObjectBase, RealmObject { static var _defaultsSet = false; - Foo({ - int x = 0, - }) { + Foo({int x = 0}) { if (!_defaultsSet) { - _defaultsSet = RealmObjectBase.setDefaults({ - 'x': 0, - }); + _defaultsSet = RealmObjectBase.setDefaults({'x': 0}); } RealmObjectBase.set(this, 'x', x); } @@ -41,17 +38,13 @@ class Foo extends _Foo with RealmEntity, RealmObjectBase, RealmObject { Foo freeze() => RealmObjectBase.freezeObject(this); EJsonValue toEJson() { - return { - 'x': x.toEJson(), - }; + return {'x': x.toEJson()}; } static EJsonValue _toEJson(Foo value) => value.toEJson(); static Foo _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); - return Foo( - x: fromEJson(ejson['x'], defaultValue: 0), - ); + return Foo(x: fromEJson(ejson['x'], defaultValue: 0)); } static final schema = () { diff --git a/packages/realm_generator/test/good_test_data/primary_key.expected b/packages/realm_generator/test/good_test_data/primary_key.expected index f51109b6d..a28e5196d 100644 --- a/packages/realm_generator/test/good_test_data/primary_key.expected +++ b/packages/realm_generator/test/good_test_data/primary_key.expected @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'primary_key.dart'; @@ -9,9 +10,7 @@ part of 'primary_key.dart'; // coverage:ignore-file // ignore_for_file: type=lint class IntPK extends _IntPK with RealmEntity, RealmObjectBase, RealmObject { - IntPK( - int id, - ) { + IntPK(int id) { RealmObjectBase.set(this, 'id', id); } @@ -34,21 +33,14 @@ class IntPK extends _IntPK with RealmEntity, RealmObjectBase, RealmObject { IntPK freeze() => RealmObjectBase.freezeObject(this); EJsonValue toEJson() { - return { - 'id': id.toEJson(), - }; + return {'id': id.toEJson()}; } static EJsonValue _toEJson(IntPK value) => value.toEJson(); static IntPK _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); return switch (ejson) { - { - 'id': EJsonValue id, - } => - IntPK( - fromEJson(id), - ), + {'id': EJsonValue id} => IntPK(fromEJson(id)), _ => raiseInvalidEJson(ejson), }; } @@ -67,9 +59,7 @@ class IntPK extends _IntPK with RealmEntity, RealmObjectBase, RealmObject { class NullableIntPK extends _NullableIntPK with RealmEntity, RealmObjectBase, RealmObject { - NullableIntPK( - int? id, - ) { + NullableIntPK(int? id) { RealmObjectBase.set(this, 'id', id); } @@ -85,29 +75,23 @@ class NullableIntPK extends _NullableIntPK RealmObjectBase.getChanges(this); @override - Stream> changesFor( - [List? keyPaths]) => + Stream> changesFor([ + List? keyPaths, + ]) => RealmObjectBase.getChangesFor(this, keyPaths); @override NullableIntPK freeze() => RealmObjectBase.freezeObject(this); EJsonValue toEJson() { - return { - 'id': id.toEJson(), - }; + return {'id': id.toEJson()}; } static EJsonValue _toEJson(NullableIntPK value) => value.toEJson(); static NullableIntPK _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); return switch (ejson) { - { - 'id': EJsonValue id, - } => - NullableIntPK( - fromEJson(ejson['id']), - ), + {'id': EJsonValue id} => NullableIntPK(fromEJson(ejson['id'])), _ => raiseInvalidEJson(ejson), }; } @@ -116,10 +100,18 @@ class NullableIntPK extends _NullableIntPK RealmObjectBase.registerFactory(NullableIntPK._); register(_toEJson, _fromEJson); return const SchemaObject( - ObjectType.realmObject, NullableIntPK, 'NullableIntPK', [ - SchemaProperty('id', RealmPropertyType.int, - optional: true, primaryKey: true), - ]); + ObjectType.realmObject, + NullableIntPK, + 'NullableIntPK', + [ + SchemaProperty( + 'id', + RealmPropertyType.int, + optional: true, + primaryKey: true, + ), + ], + ); }(); @override @@ -128,9 +120,7 @@ class NullableIntPK extends _NullableIntPK class StringPK extends _StringPK with RealmEntity, RealmObjectBase, RealmObject { - StringPK( - String id, - ) { + StringPK(String id) { RealmObjectBase.set(this, 'id', id); } @@ -153,21 +143,14 @@ class StringPK extends _StringPK StringPK freeze() => RealmObjectBase.freezeObject(this); EJsonValue toEJson() { - return { - 'id': id.toEJson(), - }; + return {'id': id.toEJson()}; } static EJsonValue _toEJson(StringPK value) => value.toEJson(); static StringPK _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); return switch (ejson) { - { - 'id': EJsonValue id, - } => - StringPK( - fromEJson(id), - ), + {'id': EJsonValue id} => StringPK(fromEJson(id)), _ => raiseInvalidEJson(ejson), }; } @@ -186,9 +169,7 @@ class StringPK extends _StringPK class NullableStringPK extends _NullableStringPK with RealmEntity, RealmObjectBase, RealmObject { - NullableStringPK( - String? id, - ) { + NullableStringPK(String? id) { RealmObjectBase.set(this, 'id', id); } @@ -204,8 +185,9 @@ class NullableStringPK extends _NullableStringPK RealmObjectBase.getChanges(this); @override - Stream> changesFor( - [List? keyPaths]) => + Stream> changesFor([ + List? keyPaths, + ]) => RealmObjectBase.getChangesFor(this, keyPaths); @override @@ -213,21 +195,14 @@ class NullableStringPK extends _NullableStringPK RealmObjectBase.freezeObject(this); EJsonValue toEJson() { - return { - 'id': id.toEJson(), - }; + return {'id': id.toEJson()}; } static EJsonValue _toEJson(NullableStringPK value) => value.toEJson(); static NullableStringPK _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); return switch (ejson) { - { - 'id': EJsonValue id, - } => - NullableStringPK( - fromEJson(ejson['id']), - ), + {'id': EJsonValue id} => NullableStringPK(fromEJson(ejson['id'])), _ => raiseInvalidEJson(ejson), }; } @@ -236,10 +211,18 @@ class NullableStringPK extends _NullableStringPK RealmObjectBase.registerFactory(NullableStringPK._); register(_toEJson, _fromEJson); return const SchemaObject( - ObjectType.realmObject, NullableStringPK, 'NullableStringPK', [ - SchemaProperty('id', RealmPropertyType.string, - optional: true, primaryKey: true), - ]); + ObjectType.realmObject, + NullableStringPK, + 'NullableStringPK', + [ + SchemaProperty( + 'id', + RealmPropertyType.string, + optional: true, + primaryKey: true, + ), + ], + ); }(); @override @@ -248,9 +231,7 @@ class NullableStringPK extends _NullableStringPK class ObjectIdPK extends _ObjectIdPK with RealmEntity, RealmObjectBase, RealmObject { - ObjectIdPK( - ObjectId id, - ) { + ObjectIdPK(ObjectId id) { RealmObjectBase.set(this, 'id', id); } @@ -273,21 +254,14 @@ class ObjectIdPK extends _ObjectIdPK ObjectIdPK freeze() => RealmObjectBase.freezeObject(this); EJsonValue toEJson() { - return { - 'id': id.toEJson(), - }; + return {'id': id.toEJson()}; } static EJsonValue _toEJson(ObjectIdPK value) => value.toEJson(); static ObjectIdPK _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); return switch (ejson) { - { - 'id': EJsonValue id, - } => - ObjectIdPK( - fromEJson(id), - ), + {'id': EJsonValue id} => ObjectIdPK(fromEJson(id)), _ => raiseInvalidEJson(ejson), }; } @@ -295,9 +269,12 @@ class ObjectIdPK extends _ObjectIdPK static final schema = () { RealmObjectBase.registerFactory(ObjectIdPK._); register(_toEJson, _fromEJson); - return const SchemaObject(ObjectType.realmObject, ObjectIdPK, 'ObjectIdPK', [ - SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), - ]); + return const SchemaObject( + ObjectType.realmObject, + ObjectIdPK, + 'ObjectIdPK', + [SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true)], + ); }(); @override @@ -306,9 +283,7 @@ class ObjectIdPK extends _ObjectIdPK class NullableObjectIdPK extends _NullableObjectIdPK with RealmEntity, RealmObjectBase, RealmObject { - NullableObjectIdPK( - ObjectId? id, - ) { + NullableObjectIdPK(ObjectId? id) { RealmObjectBase.set(this, 'id', id); } @@ -324,8 +299,9 @@ class NullableObjectIdPK extends _NullableObjectIdPK RealmObjectBase.getChanges(this); @override - Stream> changesFor( - [List? keyPaths]) => + Stream> changesFor([ + List? keyPaths, + ]) => RealmObjectBase.getChangesFor(this, keyPaths); @override @@ -333,21 +309,14 @@ class NullableObjectIdPK extends _NullableObjectIdPK RealmObjectBase.freezeObject(this); EJsonValue toEJson() { - return { - 'id': id.toEJson(), - }; + return {'id': id.toEJson()}; } static EJsonValue _toEJson(NullableObjectIdPK value) => value.toEJson(); static NullableObjectIdPK _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); return switch (ejson) { - { - 'id': EJsonValue id, - } => - NullableObjectIdPK( - fromEJson(ejson['id']), - ), + {'id': EJsonValue id} => NullableObjectIdPK(fromEJson(ejson['id'])), _ => raiseInvalidEJson(ejson), }; } @@ -356,10 +325,18 @@ class NullableObjectIdPK extends _NullableObjectIdPK RealmObjectBase.registerFactory(NullableObjectIdPK._); register(_toEJson, _fromEJson); return const SchemaObject( - ObjectType.realmObject, NullableObjectIdPK, 'NullableObjectIdPK', [ - SchemaProperty('id', RealmPropertyType.objectid, - optional: true, primaryKey: true), - ]); + ObjectType.realmObject, + NullableObjectIdPK, + 'NullableObjectIdPK', + [ + SchemaProperty( + 'id', + RealmPropertyType.objectid, + optional: true, + primaryKey: true, + ), + ], + ); }(); @override @@ -367,9 +344,7 @@ class NullableObjectIdPK extends _NullableObjectIdPK } class UuidPK extends _UuidPK with RealmEntity, RealmObjectBase, RealmObject { - UuidPK( - Uuid id, - ) { + UuidPK(Uuid id) { RealmObjectBase.set(this, 'id', id); } @@ -392,21 +367,14 @@ class UuidPK extends _UuidPK with RealmEntity, RealmObjectBase, RealmObject { UuidPK freeze() => RealmObjectBase.freezeObject(this); EJsonValue toEJson() { - return { - 'id': id.toEJson(), - }; + return {'id': id.toEJson()}; } static EJsonValue _toEJson(UuidPK value) => value.toEJson(); static UuidPK _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); return switch (ejson) { - { - 'id': EJsonValue id, - } => - UuidPK( - fromEJson(id), - ), + {'id': EJsonValue id} => UuidPK(fromEJson(id)), _ => raiseInvalidEJson(ejson), }; } @@ -425,9 +393,7 @@ class UuidPK extends _UuidPK with RealmEntity, RealmObjectBase, RealmObject { class NullableUuidPK extends _NullableUuidPK with RealmEntity, RealmObjectBase, RealmObject { - NullableUuidPK( - Uuid? id, - ) { + NullableUuidPK(Uuid? id) { RealmObjectBase.set(this, 'id', id); } @@ -443,29 +409,23 @@ class NullableUuidPK extends _NullableUuidPK RealmObjectBase.getChanges(this); @override - Stream> changesFor( - [List? keyPaths]) => + Stream> changesFor([ + List? keyPaths, + ]) => RealmObjectBase.getChangesFor(this, keyPaths); @override NullableUuidPK freeze() => RealmObjectBase.freezeObject(this); EJsonValue toEJson() { - return { - 'id': id.toEJson(), - }; + return {'id': id.toEJson()}; } static EJsonValue _toEJson(NullableUuidPK value) => value.toEJson(); static NullableUuidPK _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); return switch (ejson) { - { - 'id': EJsonValue id, - } => - NullableUuidPK( - fromEJson(ejson['id']), - ), + {'id': EJsonValue id} => NullableUuidPK(fromEJson(ejson['id'])), _ => raiseInvalidEJson(ejson), }; } @@ -474,10 +434,18 @@ class NullableUuidPK extends _NullableUuidPK RealmObjectBase.registerFactory(NullableUuidPK._); register(_toEJson, _fromEJson); return const SchemaObject( - ObjectType.realmObject, NullableUuidPK, 'NullableUuidPK', [ - SchemaProperty('id', RealmPropertyType.uuid, - optional: true, primaryKey: true), - ]); + ObjectType.realmObject, + NullableUuidPK, + 'NullableUuidPK', + [ + SchemaProperty( + 'id', + RealmPropertyType.uuid, + optional: true, + primaryKey: true, + ), + ], + ); }(); @override diff --git a/packages/realm_generator/test/good_test_data/private_fields.expected b/packages/realm_generator/test/good_test_data/private_fields.expected index d3f826a06..f8c681864 100644 --- a/packages/realm_generator/test/good_test_data/private_fields.expected +++ b/packages/realm_generator/test/good_test_data/private_fields.expected @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'private_fields.dart'; @@ -12,10 +13,7 @@ class WithPrivateFields extends _WithPrivateFields with RealmEntity, RealmObjectBase, RealmObject { static var _defaultsSet = false; - WithPrivateFields( - String _plain, { - int withDefault = 0, - }) { + WithPrivateFields(String _plain, {int withDefault = 0}) { if (!_defaultsSet) { _defaultsSet = RealmObjectBase.setDefaults({ '_withDefault': 0, @@ -43,8 +41,9 @@ class WithPrivateFields extends _WithPrivateFields RealmObjectBase.getChanges(this); @override - Stream> changesFor( - [List? keyPaths]) => + Stream> changesFor([ + List? keyPaths, + ]) => RealmObjectBase.getChangesFor(this, keyPaths); @override @@ -62,10 +61,7 @@ class WithPrivateFields extends _WithPrivateFields static WithPrivateFields _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); return switch (ejson) { - { - '_plain': EJsonValue _plain, - } => - WithPrivateFields( + {'_plain': EJsonValue _plain} => WithPrivateFields( fromEJson(_plain), withDefault: fromEJson(ejson['_withDefault'], defaultValue: 0), ), @@ -77,10 +73,14 @@ class WithPrivateFields extends _WithPrivateFields RealmObjectBase.registerFactory(WithPrivateFields._); register(_toEJson, _fromEJson); return const SchemaObject( - ObjectType.realmObject, WithPrivateFields, 'WithPrivateFields', [ - SchemaProperty('_plain', RealmPropertyType.string), - SchemaProperty('_withDefault', RealmPropertyType.int), - ]); + ObjectType.realmObject, + WithPrivateFields, + 'WithPrivateFields', + [ + SchemaProperty('_plain', RealmPropertyType.string), + SchemaProperty('_withDefault', RealmPropertyType.int), + ], + ); }(); @override diff --git a/packages/realm_generator/test/good_test_data/realm_set.expected b/packages/realm_generator/test/good_test_data/realm_set.expected index 0201e7a84..300b12ff0 100644 --- a/packages/realm_generator/test/good_test_data/realm_set.expected +++ b/packages/realm_generator/test/good_test_data/realm_set.expected @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'realm_set.dart'; @@ -9,9 +10,7 @@ part of 'realm_set.dart'; // coverage:ignore-file // ignore_for_file: type=lint class Car extends _Car with RealmEntity, RealmObjectBase, RealmObject { - Car( - String make, - ) { + Car(String make) { RealmObjectBase.set(this, 'make', make); } @@ -34,21 +33,14 @@ class Car extends _Car with RealmEntity, RealmObjectBase, RealmObject { Car freeze() => RealmObjectBase.freezeObject(this); EJsonValue toEJson() { - return { - 'make': make.toEJson(), - }; + return {'make': make.toEJson()}; } static EJsonValue _toEJson(Car value) => value.toEJson(); static Car _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); return switch (ejson) { - { - 'make': EJsonValue make, - } => - Car( - fromEJson(make), - ), + {'make': EJsonValue make} => Car(fromEJson(make)), _ => raiseInvalidEJson(ejson), }; } @@ -88,36 +80,81 @@ class RealmSets extends _RealmSets }) { RealmObjectBase.set(this, 'key', key); RealmObjectBase.set>( - this, 'boolSet', RealmSet(boolSet)); + this, + 'boolSet', + RealmSet(boolSet), + ); RealmObjectBase.set>( - this, 'nullableBoolSet', RealmSet(nullableBoolSet)); + this, + 'nullableBoolSet', + RealmSet(nullableBoolSet), + ); RealmObjectBase.set>(this, 'intSet', RealmSet(intSet)); RealmObjectBase.set>( - this, 'nullableintSet', RealmSet(nullableintSet)); + this, + 'nullableintSet', + RealmSet(nullableintSet), + ); RealmObjectBase.set>( - this, 'stringSet', RealmSet(stringSet)); + this, + 'stringSet', + RealmSet(stringSet), + ); RealmObjectBase.set>( - this, 'nullablestringSet', RealmSet(nullablestringSet)); + this, + 'nullablestringSet', + RealmSet(nullablestringSet), + ); RealmObjectBase.set>( - this, 'doubleSet', RealmSet(doubleSet)); + this, + 'doubleSet', + RealmSet(doubleSet), + ); RealmObjectBase.set>( - this, 'nullabledoubleSet', RealmSet(nullabledoubleSet)); + this, + 'nullabledoubleSet', + RealmSet(nullabledoubleSet), + ); RealmObjectBase.set>( - this, 'dateTimeSet', RealmSet(dateTimeSet)); + this, + 'dateTimeSet', + RealmSet(dateTimeSet), + ); RealmObjectBase.set>( - this, 'nullabledateTimeSet', RealmSet(nullabledateTimeSet)); + this, + 'nullabledateTimeSet', + RealmSet(nullabledateTimeSet), + ); RealmObjectBase.set>( - this, 'objectIdSet', RealmSet(objectIdSet)); + this, + 'objectIdSet', + RealmSet(objectIdSet), + ); RealmObjectBase.set>( - this, 'nullableobjectIdSet', RealmSet(nullableobjectIdSet)); + this, + 'nullableobjectIdSet', + RealmSet(nullableobjectIdSet), + ); RealmObjectBase.set>( - this, 'uuidSet', RealmSet(uuidSet)); + this, + 'uuidSet', + RealmSet(uuidSet), + ); RealmObjectBase.set>( - this, 'nullableuuidSet', RealmSet(nullableuuidSet)); + this, + 'nullableuuidSet', + RealmSet(nullableuuidSet), + ); RealmObjectBase.set>( - this, 'realmValueSet', RealmSet(realmValueSet)); + this, + 'realmValueSet', + RealmSet(realmValueSet), + ); RealmObjectBase.set>( - this, 'realmObjectsSet', RealmSet(realmObjectsSet)); + this, + 'realmObjectsSet', + RealmSet(realmObjectsSet), + ); } RealmSets._(); @@ -280,10 +317,7 @@ class RealmSets extends _RealmSets static RealmSets _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); return switch (ejson) { - { - 'key': EJsonValue key, - } => - RealmSets( + {'key': EJsonValue key} => RealmSets( fromEJson(key), boolSet: fromEJson(ejson['boolSet']), nullableBoolSet: fromEJson(ejson['nullableBoolSet']), @@ -311,38 +345,95 @@ class RealmSets extends _RealmSets register(_toEJson, _fromEJson); return const SchemaObject(ObjectType.realmObject, RealmSets, 'RealmSets', [ SchemaProperty('key', RealmPropertyType.int, primaryKey: true), - SchemaProperty('boolSet', RealmPropertyType.bool, - collectionType: RealmCollectionType.set), - SchemaProperty('nullableBoolSet', RealmPropertyType.bool, - optional: true, collectionType: RealmCollectionType.set), - SchemaProperty('intSet', RealmPropertyType.int, - collectionType: RealmCollectionType.set), - SchemaProperty('nullableintSet', RealmPropertyType.int, - optional: true, collectionType: RealmCollectionType.set), - SchemaProperty('stringSet', RealmPropertyType.string, - collectionType: RealmCollectionType.set), - SchemaProperty('nullablestringSet', RealmPropertyType.string, - optional: true, collectionType: RealmCollectionType.set), - SchemaProperty('doubleSet', RealmPropertyType.double, - collectionType: RealmCollectionType.set), - SchemaProperty('nullabledoubleSet', RealmPropertyType.double, - optional: true, collectionType: RealmCollectionType.set), - SchemaProperty('dateTimeSet', RealmPropertyType.timestamp, - collectionType: RealmCollectionType.set), - SchemaProperty('nullabledateTimeSet', RealmPropertyType.timestamp, - optional: true, collectionType: RealmCollectionType.set), - SchemaProperty('objectIdSet', RealmPropertyType.objectid, - collectionType: RealmCollectionType.set), - SchemaProperty('nullableobjectIdSet', RealmPropertyType.objectid, - optional: true, collectionType: RealmCollectionType.set), - SchemaProperty('uuidSet', RealmPropertyType.uuid, - collectionType: RealmCollectionType.set), - SchemaProperty('nullableuuidSet', RealmPropertyType.uuid, - optional: true, collectionType: RealmCollectionType.set), - SchemaProperty('realmValueSet', RealmPropertyType.mixed, - optional: true, collectionType: RealmCollectionType.set), - SchemaProperty('realmObjectsSet', RealmPropertyType.object, - linkTarget: 'Car', collectionType: RealmCollectionType.set), + SchemaProperty( + 'boolSet', + RealmPropertyType.bool, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'nullableBoolSet', + RealmPropertyType.bool, + optional: true, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'intSet', + RealmPropertyType.int, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'nullableintSet', + RealmPropertyType.int, + optional: true, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'stringSet', + RealmPropertyType.string, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'nullablestringSet', + RealmPropertyType.string, + optional: true, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'doubleSet', + RealmPropertyType.double, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'nullabledoubleSet', + RealmPropertyType.double, + optional: true, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'dateTimeSet', + RealmPropertyType.timestamp, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'nullabledateTimeSet', + RealmPropertyType.timestamp, + optional: true, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'objectIdSet', + RealmPropertyType.objectid, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'nullableobjectIdSet', + RealmPropertyType.objectid, + optional: true, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'uuidSet', + RealmPropertyType.uuid, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'nullableuuidSet', + RealmPropertyType.uuid, + optional: true, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'realmValueSet', + RealmPropertyType.mixed, + optional: true, + collectionType: RealmCollectionType.set, + ), + SchemaProperty( + 'realmObjectsSet', + RealmPropertyType.object, + linkTarget: 'Car', + collectionType: RealmCollectionType.set, + ), ]); }(); diff --git a/packages/realm_generator/test/good_test_data/required_argument.expected b/packages/realm_generator/test/good_test_data/required_argument.expected index b8ed8a522..2b84cf765 100644 --- a/packages/realm_generator/test/good_test_data/required_argument.expected +++ b/packages/realm_generator/test/good_test_data/required_argument.expected @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'required_argument.dart'; @@ -9,9 +10,7 @@ part of 'required_argument.dart'; // coverage:ignore-file // ignore_for_file: type=lint class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { - Person( - String name, - ) { + Person(String name) { RealmObjectBase.set(this, 'name', name); } @@ -34,21 +33,14 @@ class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { Person freeze() => RealmObjectBase.freezeObject(this); EJsonValue toEJson() { - return { - 'name': name.toEJson(), - }; + return {'name': name.toEJson()}; } static EJsonValue _toEJson(Person value) => value.toEJson(); static Person _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); return switch (ejson) { - { - 'name': EJsonValue name, - } => - Person( - fromEJson(name), - ), + {'name': EJsonValue name} => Person(fromEJson(name)), _ => raiseInvalidEJson(ejson), }; } diff --git a/packages/realm_generator/test/good_test_data/required_argument_with_default_value.expected b/packages/realm_generator/test/good_test_data/required_argument_with_default_value.expected index 79b83d1a4..e194be8b4 100644 --- a/packages/realm_generator/test/good_test_data/required_argument_with_default_value.expected +++ b/packages/realm_generator/test/good_test_data/required_argument_with_default_value.expected @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'required_argument_with_default_value.dart'; @@ -11,13 +12,9 @@ part of 'required_argument_with_default_value.dart'; class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { static var _defaultsSet = false; - Person({ - int age = 47, - }) { + Person({int age = 47}) { if (!_defaultsSet) { - _defaultsSet = RealmObjectBase.setDefaults({ - 'age': 47, - }); + _defaultsSet = RealmObjectBase.setDefaults({'age': 47}); } RealmObjectBase.set(this, 'age', age); } @@ -41,17 +38,13 @@ class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { Person freeze() => RealmObjectBase.freezeObject(this); EJsonValue toEJson() { - return { - 'age': age.toEJson(), - }; + return {'age': age.toEJson()}; } static EJsonValue _toEJson(Person value) => value.toEJson(); static Person _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); - return Person( - age: fromEJson(ejson['age'], defaultValue: 47), - ); + return Person(age: fromEJson(ejson['age'], defaultValue: 47)); } static final schema = () { diff --git a/packages/realm_generator/test/good_test_data/user_defined_getter.expected b/packages/realm_generator/test/good_test_data/user_defined_getter.expected index cff37dff7..01cfae963 100644 --- a/packages/realm_generator/test/good_test_data/user_defined_getter.expected +++ b/packages/realm_generator/test/good_test_data/user_defined_getter.expected @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'user_defined_getter.dart'; @@ -9,9 +10,7 @@ part of 'user_defined_getter.dart'; // coverage:ignore-file // ignore_for_file: type=lint class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { - Person( - String name, - ) { + Person(String name) { RealmObjectBase.set(this, 'name', name); } @@ -34,21 +33,14 @@ class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { Person freeze() => RealmObjectBase.freezeObject(this); EJsonValue toEJson() { - return { - 'name': name.toEJson(), - }; + return {'name': name.toEJson()}; } static EJsonValue _toEJson(Person value) => value.toEJson(); static Person _fromEJson(EJsonValue ejson) { if (ejson is! Map) return raiseInvalidEJson(ejson); return switch (ejson) { - { - 'name': EJsonValue name, - } => - Person( - fromEJson(name), - ), + {'name': EJsonValue name} => Person(fromEJson(name)), _ => raiseInvalidEJson(ejson), }; } diff --git a/packages/realm_generator/test/test_util.dart b/packages/realm_generator/test/test_util.dart index 10c23a6f3..cde9b7602 100644 --- a/packages/realm_generator/test/test_util.dart +++ b/packages/realm_generator/test/test_util.dart @@ -6,8 +6,9 @@ import 'package:logging/logging.dart'; import 'package:meta/meta.dart'; import 'package:realm_generator/realm_generator.dart'; import 'package:test/test.dart'; +import 'package:pub_semver/src/version.dart'; -final _formatter = DartFormatter(lineEnding: '\n'); +final _formatter = DartFormatter(lineEnding: '\n', languageVersion: Version(3, 3, 0)); /// Used to test both correct an erroneous compilation. /// [source] can be a [File] or a [String].