From 428c19437eb32591f5ab32a49cbcc5896851eff3 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Sun, 22 Nov 2020 11:32:14 +0100 Subject: [PATCH 01/26] Updated versions --- kiwi/pubspec.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kiwi/pubspec.yaml b/kiwi/pubspec.yaml index affa9cb..0aac0fc 100644 --- a/kiwi/pubspec.yaml +++ b/kiwi/pubspec.yaml @@ -1,13 +1,13 @@ name: kiwi description: A simple yet efficient dependency injection container for Dart and Flutter (can be coupled with the kiwi_generator package). -version: 2.1.1 +version: 3.0.0-nullsafety.0 homepage: https://github.com/vanlooverenkoen/kiwi/tree/master/kiwi environment: - sdk: '>=2.2.0 <3.0.0' + sdk: ">=2.12.0-0 <3.0.0" dependencies: - meta: ^1.2.3 + meta: ^1.3.0-nullsafety.6 dev_dependencies: - test: ^1.15.4 + test: ^1.16.0-nullsafety.12 From b0d0664b59ed509e45b24b87655ce74c4e0fa50d Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Sun, 22 Nov 2020 12:16:57 +0100 Subject: [PATCH 02/26] #51: Added the basic migration to support nullability for kiwi (no support yet for the kiwi_generator) --- kiwi/example/kiwi_example.dart | 2 +- kiwi/lib/src/annotations.dart | 16 ++++----- kiwi/lib/src/kiwi_container.dart | 61 ++++++++++++++++---------------- 3 files changed, 38 insertions(+), 41 deletions(-) diff --git a/kiwi/example/kiwi_example.dart b/kiwi/example/kiwi_example.dart index 907ae40..cd89411 100644 --- a/kiwi/example/kiwi_example.dart +++ b/kiwi/example/kiwi_example.dart @@ -4,7 +4,7 @@ main() { KiwiContainer container = KiwiContainer(); container.registerInstance(Logger()); container.registerSingleton((c) => Logger(), name: 'logA'); - container.registerFactory((c) => ServiceA(c.resolve('logA'))); + container.registerFactory((c) => ServiceA(c.resolve('logA')!)); } class Service {} diff --git a/kiwi/lib/src/annotations.dart b/kiwi/lib/src/annotations.dart index 72a052b..94a3650 100644 --- a/kiwi/lib/src/annotations.dart +++ b/kiwi/lib/src/annotations.dart @@ -10,8 +10,7 @@ class Register { this.from, this.resolvers, this.constructorName, - }) : assert(type != null), - oneTime = null; + }) : oneTime = null; /// Create an annotation that will generate a `registerSingleton` method. const Register.singleton( @@ -20,31 +19,30 @@ class Register { this.from, this.resolvers, this.constructorName, - }) : assert(type != null), - oneTime = true; + }) : oneTime = true; /// The type to register. final Type type; /// The type to create when requesting [type]. - final Type from; + final Type? from; /// The name under which the factory will be registered /// /// You must provide the same name in [KiwiContainer.resolve] /// to get the same factory. - final String name; + final String? name; /// A map that give for a type, the name under which it should be resolved /// /// For example if you have registered a type T under the name /// 'myType', you have to specify it in this map in order /// to use it instead of the default value for the type T. - final Map resolvers; + final Map? resolvers; /// The name of the constructor to use inside the factory. - final String constructorName; + final String? constructorName; /// Whether the factory has to be created only one time. - final bool oneTime; + final bool? oneTime; } diff --git a/kiwi/lib/src/kiwi_container.dart b/kiwi/lib/src/kiwi_container.dart index 36ed978..5d51753 100644 --- a/kiwi/lib/src/kiwi_container.dart +++ b/kiwi/lib/src/kiwi_container.dart @@ -7,15 +7,14 @@ typedef T Factory(KiwiContainer container); /// A simple service container. class KiwiContainer { /// Creates a scoped container. - KiwiContainer.scoped() - : _namedProviders = Map>>(); + KiwiContainer.scoped() : _namedProviders = Map>>(); static final KiwiContainer _instance = KiwiContainer.scoped(); /// Always returns a singleton representing the only container to be alive. factory KiwiContainer() => _instance; - final Map>> _namedProviders; + final Map>> _namedProviders; /// Whether ignoring KiwiErrors in the following cases: /// * if you register the same type under the same name a second time. @@ -34,7 +33,7 @@ class KiwiContainer { /// to [KiwiContainer.resolve]. void registerInstance( S instance, { - String name, + String? name, }) { _setProvider(name, _Provider.instance(instance)); } @@ -48,7 +47,7 @@ class KiwiContainer { /// to [KiwiContainer.resolve]. void registerFactory( Factory factory, { - String name, + String? name, }) { _setProvider(name, _Provider.factory(factory)); } @@ -63,7 +62,7 @@ class KiwiContainer { /// to [KiwiContainer.resolve]. void registerSingleton( Factory factory, { - String name, + String? name, }) { _setProvider(name, _Provider.singleton(factory)); } @@ -71,7 +70,7 @@ class KiwiContainer { /// Removes the entry previously registered for the type [T]. /// /// If [name] is set, removes the one registered for that name. - void unregister([String name]) { + void unregister([String? name]) { if (!silent && !(_namedProviders[name]?.containsKey(T) ?? false)) { throw KiwiError( 'Failed to unregister `$T`:\n\nThe type `$T` was not registered${name == null ? '' : ' for the name `$name`'}\n\nMake sure `$T` is added to your KiwiContainer and rerun build_runner build\n(If you are using the kiwi_generator)\n\nWhen using Flutter, most of the time a hot restart is required to setup the KiwiContainer again.'); @@ -88,17 +87,17 @@ class KiwiContainer { /// /// * [KiwiContainer.registerFactory] for register a builder function. /// * [KiwiContainer.registerInstance] for register an instance. - T resolve([String name]) { - Map> providers = _namedProviders[name]; - if (!silent && !(providers?.containsKey(T) ?? false)) { + T? resolve([String? name]) { + final providers = _namedProviders[name] ?? Map>(); + if (!silent && !(providers.containsKey(T))) { throw KiwiError( 'Failed to resolve `$T`:\n\nThe type `$T` was not registered${name == null ? '' : ' for the name `$name`'}\n\nMake sure `$T` is added to your KiwiContainer and rerun build_runner build\n(If you are using the kiwi_generator)\n\nWhen using Flutter, most of the time a hot restart is required to setup the KiwiContainer again.'); } - if (providers == null) { - return null; - } - return providers[T]?.get(this); + final value = providers[T]?.get(this); + if (value == null) return null; + if (value is T) return value as T; + return null; } /// Attemps to resolve the type [S] and tries to cast it to T. @@ -114,16 +113,17 @@ class KiwiContainer { /// * [KiwiContainer.registerFactory] for register a builder function. /// * [KiwiContainer.registerInstance] for register an instance. @visibleForTesting - T resolveAs([String name]) { + T? resolveAs([String? name]) { final obj = resolve(name); if (!silent && !(obj is T)) { throw KiwiError( 'Failed to resolve `$S` as `$T`:\n\nThe type `$S` as `$T` was not registered${name == null ? '' : ' for the name `$name`'}\n\nMake sure `$T` is added to your KiwiContainer and rerun build_runner build\n(If you are using the kiwi_generator)\n\nWhen using Flutter, most of the time a hot restart is required to setup the KiwiContainer again.'); } - return obj; + if (obj == null) return null; + return obj as T; } - T call([String name]) => resolve(name); + T? call([String? name]) => resolve(name); /// Removes all instances and builders from the container. /// @@ -132,32 +132,31 @@ class KiwiContainer { _namedProviders.clear(); } - void _setProvider(String name, _Provider provider) { - if (!silent && - (_namedProviders.containsKey(name) && - _namedProviders[name].containsKey(T))) { - throw KiwiError( - 'The type `$T` was already registered${name == null ? '' : ' for the name `$name`'}'); + void _setProvider(String? name, _Provider provider) { + final nameProviders = _namedProviders; + if (!silent && (nameProviders.containsKey(name) && nameProviders[name]!.containsKey(T))) { + throw KiwiError('The type `$T` was already registered${name == null ? '' : ' for the name `$name`'}'); } - _namedProviders.putIfAbsent(name, () => Map>())[T] = - provider; + _namedProviders.putIfAbsent(name, () => Map>())[T] = provider as _Provider; } } class _Provider { _Provider.instance(this.object) - : instanceBuilder = null, + : _instanceBuilder = null, _oneTime = false; - _Provider.factory(this.instanceBuilder) : _oneTime = false; + _Provider.factory(this._instanceBuilder) : _oneTime = false; - _Provider.singleton(this.instanceBuilder) : _oneTime = true; + _Provider.singleton(this._instanceBuilder) : _oneTime = true; - final Factory instanceBuilder; - T object; + final Factory? _instanceBuilder; + T? object; bool _oneTime = false; - T get(KiwiContainer container) { + T? get(KiwiContainer container) { + final instanceBuilder = _instanceBuilder; + if (_oneTime && instanceBuilder != null) { object = instanceBuilder(container); _oneTime = false; From fb94167ff737afe9db35e27640461486057b0c23 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Thu, 4 Mar 2021 10:26:16 +0100 Subject: [PATCH 03/26] #51: added nullsafety support for the generator. (but dependencies are not ready yet) --- flutter_example/pubspec.yaml | 2 +- kiwi/pubspec.yaml | 4 +- .../example/kiwi_generator_example.g.dart | 23 +++--- kiwi_generator/lib/builder.dart | 2 +- .../lib/src/kiwi_injector_generator.dart | 70 +++++++++++-------- .../lib/src/model/kiwi_generator_error.dart | 7 +- .../lib/src/util/list_extensions.dart | 17 +++++ kiwi_generator/pubspec.yaml | 24 +++---- kiwi_generator/test/utils/test.dart | 4 +- 9 files changed, 88 insertions(+), 65 deletions(-) create mode 100644 kiwi_generator/lib/src/util/list_extensions.dart diff --git a/flutter_example/pubspec.yaml b/flutter_example/pubspec.yaml index 869e77a..77c47fa 100644 --- a/flutter_example/pubspec.yaml +++ b/flutter_example/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - build_runner: ^1.10.3 + build_runner: ^1.11.5 kiwi_generator: ^2.1.1 dependency_overrides: diff --git a/kiwi/pubspec.yaml b/kiwi/pubspec.yaml index 0aac0fc..d869e2a 100644 --- a/kiwi/pubspec.yaml +++ b/kiwi/pubspec.yaml @@ -7,7 +7,7 @@ environment: sdk: ">=2.12.0-0 <3.0.0" dependencies: - meta: ^1.3.0-nullsafety.6 + meta: ^1.3.0 dev_dependencies: - test: ^1.16.0-nullsafety.12 + test: ^1.16.5 diff --git a/kiwi_generator/example/kiwi_generator_example.g.dart b/kiwi_generator/example/kiwi_generator_example.g.dart index baef900..ff7f0e1 100644 --- a/kiwi_generator/example/kiwi_generator_example.g.dart +++ b/kiwi_generator/example/kiwi_generator_example.g.dart @@ -8,34 +8,30 @@ part of 'kiwi_generator_example.dart'; class _$Injector extends Injector { @override - void configureWithScopedContainer(KiwiContainer scopedContainer) { + void configureWithScopedContainer(KiwiContainer? scopedContainer) { final KiwiContainer container = scopedContainer ?? KiwiContainer(); container.registerSingleton((c) => ServiceA()); container.registerFactory((c) => ServiceB(c())); container.registerFactory((c) => ServiceB(c()), name: 'factoryB'); - container.registerFactory( - (c) => ServiceC(c(), c('factoryB'))); + container.registerFactory((c) => ServiceC(c(), c())); } @override - void configureWithScopedContainer2([KiwiContainer scopedContainer]) { + void configureWithScopedContainer2([KiwiContainer? scopedContainer = null]) { final KiwiContainer container = scopedContainer ?? KiwiContainer(); - container.registerFactory( - (c) => ServiceC(c(), c('factoryB'))); + container.registerFactory((c) => ServiceC(c(), c())); } @override - void configureWithScopedContainer3({KiwiContainer scopedContainer}) { + void configureWithScopedContainer3({KiwiContainer? scopedContainer = null}) { final KiwiContainer container = scopedContainer ?? KiwiContainer(); - container.registerFactory( - (c) => ServiceC(c(), c('factoryB'))); + container.registerFactory((c) => ServiceC(c(), c())); } @override - void configureWithScopedContainer4({KiwiContainer scopedContainer}) { + void configureWithScopedContainer4({KiwiContainer? scopedContainer = null}) { final KiwiContainer container = scopedContainer ?? KiwiContainer(); - container.registerFactory( - (c) => ServiceC(c(), c('factoryB'))); + container.registerFactory((c) => ServiceC(c(), c())); } @override @@ -44,8 +40,7 @@ class _$Injector extends Injector { container.registerSingleton((c) => ServiceA()); container.registerFactory((c) => ServiceB(c())); container.registerFactory((c) => ServiceB(c()), name: 'factoryB'); - container.registerFactory( - (c) => ServiceC(c(), c('factoryB'))); + container.registerFactory((c) => ServiceC(c(), c())); } @override diff --git a/kiwi_generator/lib/builder.dart b/kiwi_generator/lib/builder.dart index 5b83ce5..03fdce0 100644 --- a/kiwi_generator/lib/builder.dart +++ b/kiwi_generator/lib/builder.dart @@ -12,7 +12,7 @@ import 'package:source_gen/source_gen.dart'; import 'src/kiwi_injector_generator.dart'; -Builder buildKiwi([BuilderOptions options]) { +Builder buildKiwi([BuilderOptions? options = null]) { return SharedPartBuilder(const [ KiwiInjectorGenerator(), ], 'kiwi'); diff --git a/kiwi_generator/lib/src/kiwi_injector_generator.dart b/kiwi_generator/lib/src/kiwi_injector_generator.dart index 0f206ae..82e3827 100644 --- a/kiwi_generator/lib/src/kiwi_injector_generator.dart +++ b/kiwi_generator/lib/src/kiwi_injector_generator.dart @@ -7,6 +7,7 @@ import 'package:built_collection/built_collection.dart'; import 'package:build/src/builder/build_step.dart'; import 'package:kiwi_generator/src/model/kiwi_generator_error.dart'; +import 'package:kiwi_generator/src/util/list_extensions.dart'; import 'package:source_gen/source_gen.dart'; import 'package:dart_style/dart_style.dart'; @@ -22,7 +23,7 @@ class KiwiInjectorGenerator extends Generator { const KiwiInjectorGenerator(); @override - String generate(LibraryReader library, BuildStep buildStep) { + String? generate(LibraryReader library, BuildStep? buildStep) { try { // An injector is an abstract class where all abstract methods are // annotated with Register. @@ -47,16 +48,19 @@ class KiwiInjectorGenerator extends Generator { } catch (e) { if (e is KiwiGeneratorError || e is UnresolvedAnnotationException) { rethrow; - } else { + } else if (e is Error) { throw KiwiGeneratorError( 'Something went wrong with the KiwiGenerator. Please create a new ticket with a copy of your error to https://github.com/vanlooverenkoen/kiwi/issues/new?labels=kiwi_generator,bug', error: e); + } else { + throw KiwiGeneratorError( + 'Something went wrong with the KiwiGenerator. Please create a new ticket with a copy of your error to https://github.com/vanlooverenkoen/kiwi/issues/new?labels=kiwi_generator,bug'); } } } Class _generateInjector( - ClassElement injector, LibraryReader library, BuildStep buildStep) { + ClassElement injector, LibraryReader library, BuildStep? buildStep) { return Class((cb) => cb ..name = '_\$${injector.name}' ..extend = refer(injector.name) @@ -75,12 +79,12 @@ class KiwiInjectorGenerator extends Generator { throw KiwiGeneratorError( 'Only 1 parameter is supported `KiwiContainer scopedContainer`, ${method.name} contains ${method.parameters.length} param(s)'); } - final scopedContainerParam = method.parameters.singleWhere( - (element) => - element.name == 'scopedContainer' && - element.type.getDisplayString(withNullability: false) == - 'KiwiContainer', - orElse: () => null); + final scopedContainerParam = method.parameters.singleOrNullWhere( + (element) => + element.name == 'scopedContainer' && + element.type.getDisplayString(withNullability: true) == + 'KiwiContainer', + ); return Method.returnsVoid((mb) { var scopedContainer = ''; @@ -91,7 +95,8 @@ class KiwiInjectorGenerator extends Generator { ..name = scopedContainerParam.name ..named = scopedContainerParam.isNamed ..required = scopedContainerParam.isRequiredNamed - ..type = Reference('KiwiContainer')) + ..defaultTo = Code('null') + ..type = Reference('KiwiContainer?')) ]); } else { mb.requiredParameters = ListBuilder([ @@ -99,7 +104,8 @@ class KiwiInjectorGenerator extends Generator { ..name = scopedContainerParam.name ..named = scopedContainerParam.isNamed ..required = scopedContainerParam.isRequiredNamed - ..type = Reference('KiwiContainer')) + ..defaultTo = Code('null') + ..type = Reference('KiwiContainer?')) ]); } scopedContainer = '${scopedContainerParam.name} ?? '; @@ -120,7 +126,6 @@ class KiwiInjectorGenerator extends Generator { 'final KiwiContainer container = ${scopedContainer}KiwiContainer();')) ..statements.addAll(registers)); } - return mb; }); } @@ -136,32 +141,37 @@ class KiwiInjectorGenerator extends Generator { final ConstantReader annotation = annotatedMethod.annotation; final DartObject registerObject = annotation.objectValue; - final String name = registerObject.getField('name').toStringValue(); - final DartType type = registerObject.getField('type').toTypeValue(); - final DartType concrete = registerObject.getField('from').toTypeValue(); - final DartType concreteType = concrete ?? type; + final String? name = registerObject.getField('name')?.toStringValue(); + final DartType? type = registerObject.getField('type')?.toTypeValue(); + final DartType? concrete = registerObject.getField('from')?.toTypeValue(); + final String? constructorName = + registerObject.getField('constructorName')?.toStringValue(); + final DartType? concreteType = concrete ?? type; + if (concreteType == null) { + throw KiwiGeneratorError( + 'type & from are both null. This is not allowed'); + } final String className = concreteType.getDisplayString(withNullability: false); final String typeParameters = concrete == null ? '' - : '<${type.getDisplayString(withNullability: false)}>'; + : '<${type?.getDisplayString(withNullability: false)}>'; final String nameArgument = name == null ? '' : ", name: '$name'"; - final String constructorName = - registerObject.getField('constructorName').toStringValue(); final String constructorNameArgument = constructorName == null ? '' : '.$constructorName'; - final ClassElement clazz = concreteType.element.library.getType(className); + final ClassElement? clazz = + concreteType.element?.library?.getType(className); if (clazz == null) { throw KiwiGeneratorError('$className not found'); } final bool oneTime = - registerObject.getField('oneTime').toBoolValue() ?? false; - final Map resolvers = - _computeResolvers(registerObject.getField('resolvers').toMapValue()); + registerObject.getField('oneTime')?.toBoolValue() ?? false; + final Map? resolvers = + _computeResolvers(registerObject.getField('resolvers')?.toMapValue()); final String methodSuffix = oneTime ? 'Singleton' : 'Factory'; @@ -185,7 +195,7 @@ class KiwiInjectorGenerator extends Generator { List _generateRegisterArguments( ConstructorElement constructor, - Map resolvers, + Map? resolvers, ) { return constructor.parameters .map((p) => _generateRegisterArgument(p, resolvers)) @@ -194,17 +204,17 @@ class KiwiInjectorGenerator extends Generator { String _generateRegisterArgument( ParameterElement parameter, - Map resolvers, + Map? resolvers, ) { - final String name = resolvers == null ? null : resolvers[parameter.type]; + final String? name = resolvers == null ? null : resolvers[parameter.type]; final String nameArgument = name == null ? '' : "'$name'"; return '${parameter.isNamed ? parameter.name + ': ' : ''}c<${parameter.type.getDisplayString(withNullability: false)}>($nameArgument)'; } - Map _computeResolvers( - Map resolvers, + Map? _computeResolvers( + Map? resolvers, ) { - return resolvers?.map((key, value) => - MapEntry(key.toTypeValue(), value.toStringValue())); + return resolvers?.map((key, value) => MapEntry( + key?.toTypeValue(), value?.toStringValue())); } } diff --git a/kiwi_generator/lib/src/model/kiwi_generator_error.dart b/kiwi_generator/lib/src/model/kiwi_generator_error.dart index 90991fb..c0286f1 100644 --- a/kiwi_generator/lib/src/model/kiwi_generator_error.dart +++ b/kiwi_generator/lib/src/model/kiwi_generator_error.dart @@ -1,15 +1,16 @@ class KiwiGeneratorError extends Error { final String message; - final Error error; + final Error? error; KiwiGeneratorError(this.message, {this.error}); @override String toString() { var toString = '\nKiwiGeneratorError\n\n$message\n\n'; - if (error != null) { + final internalError = error; + if (internalError != null) { toString += - '============\n${error.toString()}\n${error.stackTrace}\n============\n\n'; + '============\n${internalError.toString()}\n${internalError.stackTrace}\n============\n\n'; } return toString; } diff --git a/kiwi_generator/lib/src/util/list_extensions.dart b/kiwi_generator/lib/src/util/list_extensions.dart new file mode 100644 index 0000000..d05bbbc --- /dev/null +++ b/kiwi_generator/lib/src/util/list_extensions.dart @@ -0,0 +1,17 @@ +extension ListExtension on List { + T? singleOrNullWhere(bool test(T element)) { + late T result; + bool foundMatching = false; + for (T element in this) { + if (test(element)) { + if (foundMatching) { + throw Exception('No many results'); + } + result = element; + foundMatching = true; + } + } + if (foundMatching) return result; + return null; + } +} diff --git a/kiwi_generator/pubspec.yaml b/kiwi_generator/pubspec.yaml index 3cb4fb3..2ec193f 100644 --- a/kiwi_generator/pubspec.yaml +++ b/kiwi_generator/pubspec.yaml @@ -4,20 +4,20 @@ version: 2.1.1 homepage: https://github.com/vanlooverenkoen/kiwi/tree/master/kiwi_generator environment: - sdk: '>=2.2.0 <3.0.0' + sdk: ">=2.12.0-0 <3.0.0" dependencies: - analyzer: ^0.40.4 - build: ^1.5.0 - build_config: ^0.4.2 - code_builder: ^3.5.0 - dart_style: ^1.3.8 + analyzer: ^1.1.0 + build: ^1.6.3 + build_config: ^0.4.6 + code_builder: ^3.6.0 + dart_style: ^1.3.14 kiwi: ^2.1.1 - path: ^1.7.0 - source_gen: ^0.9.7+1 - built_collection: ^4.3.2 + path: ^1.8.0 + source_gen: ^0.9.10+3 + built_collection: ^5.0.0 dev_dependencies: - build_runner: ^1.10.3 - build_test: ^1.2.2 - test: ^1.15.4 + build_runner: ^1.11.5 + build_test: ^1.3.7 + test: ^1.16.5 diff --git a/kiwi_generator/test/utils/test.dart b/kiwi_generator/test/utils/test.dart index fd1b458..f5e47a6 100644 --- a/kiwi_generator/test/utils/test.dart +++ b/kiwi_generator/test/utils/test.dart @@ -9,13 +9,13 @@ final KiwiInjectorGenerator _injectorGenerator = const KiwiInjectorGenerator(); Future testKiwi( String fileName, - String output, + String? output, ) async { String inputFilePath = './test/inputs/$fileName.dart'; final library = await resolveCompilationUnit(inputFilePath); - String actual = _injectorGenerator.generate(library, null); + String? actual = _injectorGenerator.generate(library, null); expect(actual, output); } From 768ea740b740d3dc08b542a0070f0424ef62fc7f Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Thu, 4 Mar 2021 10:41:45 +0100 Subject: [PATCH 04/26] #51: Added a fix to the kiwi_generator that --- kiwi/pubspec.yaml | 4 ++-- kiwi_generator/lib/src/kiwi_injector_generator.dart | 6 ++++-- kiwi_generator/pubspec.yaml | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/kiwi/pubspec.yaml b/kiwi/pubspec.yaml index 0aac0fc..d869e2a 100644 --- a/kiwi/pubspec.yaml +++ b/kiwi/pubspec.yaml @@ -7,7 +7,7 @@ environment: sdk: ">=2.12.0-0 <3.0.0" dependencies: - meta: ^1.3.0-nullsafety.6 + meta: ^1.3.0 dev_dependencies: - test: ^1.16.0-nullsafety.12 + test: ^1.16.5 diff --git a/kiwi_generator/lib/src/kiwi_injector_generator.dart b/kiwi_generator/lib/src/kiwi_injector_generator.dart index 0f206ae..549b6e7 100644 --- a/kiwi_generator/lib/src/kiwi_injector_generator.dart +++ b/kiwi_generator/lib/src/kiwi_injector_generator.dart @@ -91,7 +91,8 @@ class KiwiInjectorGenerator extends Generator { ..name = scopedContainerParam.name ..named = scopedContainerParam.isNamed ..required = scopedContainerParam.isRequiredNamed - ..type = Reference('KiwiContainer')) + ..defaultTo = Code('null') + ..type = Reference('KiwiContainer?')) ]); } else { mb.requiredParameters = ListBuilder([ @@ -99,7 +100,8 @@ class KiwiInjectorGenerator extends Generator { ..name = scopedContainerParam.name ..named = scopedContainerParam.isNamed ..required = scopedContainerParam.isRequiredNamed - ..type = Reference('KiwiContainer')) + ..defaultTo = Code('null') + ..type = Reference('KiwiContainer?')) ]); } scopedContainer = '${scopedContainerParam.name} ?? '; diff --git a/kiwi_generator/pubspec.yaml b/kiwi_generator/pubspec.yaml index 3cb4fb3..ec9939e 100644 --- a/kiwi_generator/pubspec.yaml +++ b/kiwi_generator/pubspec.yaml @@ -1,6 +1,6 @@ name: kiwi_generator description: Generates dependency injection code using the kiwi package to reduce development time. -version: 2.1.1 +version: 3.0.0-nullsafety-generator.0 homepage: https://github.com/vanlooverenkoen/kiwi/tree/master/kiwi_generator environment: @@ -12,7 +12,7 @@ dependencies: build_config: ^0.4.2 code_builder: ^3.5.0 dart_style: ^1.3.8 - kiwi: ^2.1.1 + kiwi: ^3.0.0-nullsafety.0 path: ^1.7.0 source_gen: ^0.9.7+1 built_collection: ^4.3.2 From f0c86ee1b281675ac06bfb221f7ead2205e78c85 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Thu, 4 Mar 2021 12:07:38 +0100 Subject: [PATCH 05/26] Fixed the analyzer --- kiwi/lib/src/annotations.dart | 4 ++-- kiwi/lib/src/kiwi_container.dart | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/kiwi/lib/src/annotations.dart b/kiwi/lib/src/annotations.dart index 94a3650..ac619c0 100644 --- a/kiwi/lib/src/annotations.dart +++ b/kiwi/lib/src/annotations.dart @@ -10,7 +10,7 @@ class Register { this.from, this.resolvers, this.constructorName, - }) : oneTime = null; + }) : oneTime = null; /// Create an annotation that will generate a `registerSingleton` method. const Register.singleton( @@ -19,7 +19,7 @@ class Register { this.from, this.resolvers, this.constructorName, - }) : oneTime = true; + }) : oneTime = true; /// The type to register. final Type type; diff --git a/kiwi/lib/src/kiwi_container.dart b/kiwi/lib/src/kiwi_container.dart index 5d51753..e2ca979 100644 --- a/kiwi/lib/src/kiwi_container.dart +++ b/kiwi/lib/src/kiwi_container.dart @@ -7,7 +7,8 @@ typedef T Factory(KiwiContainer container); /// A simple service container. class KiwiContainer { /// Creates a scoped container. - KiwiContainer.scoped() : _namedProviders = Map>>(); + KiwiContainer.scoped() + : _namedProviders = Map>>(); static final KiwiContainer _instance = KiwiContainer.scoped(); @@ -134,10 +135,14 @@ class KiwiContainer { void _setProvider(String? name, _Provider provider) { final nameProviders = _namedProviders; - if (!silent && (nameProviders.containsKey(name) && nameProviders[name]!.containsKey(T))) { - throw KiwiError('The type `$T` was already registered${name == null ? '' : ' for the name `$name`'}'); + if (!silent && + (nameProviders.containsKey(name) && + nameProviders[name]!.containsKey(T))) { + throw KiwiError( + 'The type `$T` was already registered${name == null ? '' : ' for the name `$name`'}'); } - _namedProviders.putIfAbsent(name, () => Map>())[T] = provider as _Provider; + _namedProviders.putIfAbsent(name, () => Map>())[T] = + provider as _Provider; } } From d249ed636d8ab9b03b9d60e541f9220aed886170 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Thu, 4 Mar 2021 12:17:21 +0100 Subject: [PATCH 06/26] Added changelog kiwi --- kiwi/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kiwi/CHANGELOG.md b/kiwi/CHANGELOG.md index 80256d6..afa2de1 100644 --- a/kiwi/CHANGELOG.md +++ b/kiwi/CHANGELOG.md @@ -1,3 +1,7 @@ +## [3.0.0-nullsafety.0] - 2021-03-04 +### Added +- Nullsafety support in a dev release + ## [2.1.1] - 2020-10-24 ### Updated - Description to make the kiwi package easy to find in pub.dev From f47c257f209b1a8bc00faf0c6a97f49924ffdb3d Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Thu, 4 Mar 2021 12:18:07 +0100 Subject: [PATCH 07/26] Added changelog kiwi --- kiwi_generator/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kiwi_generator/CHANGELOG.md b/kiwi_generator/CHANGELOG.md index 73d5ebb..c7dc85a 100644 --- a/kiwi_generator/CHANGELOG.md +++ b/kiwi_generator/CHANGELOG.md @@ -1,3 +1,7 @@ +## [3.0.0-nullsafety.0] - 2021-03-04 +### Added +- Nullsafety support in a dev release (the kiwi_generator code is not yet nullsafe but the generator is) + ## [2.1.1] - 2020-10-24 ### Updated - Kiwi version to 2.1.1 From b32ada3bcbb04cff49d36e7fef86c2ddef9fd437 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Thu, 4 Mar 2021 12:20:10 +0100 Subject: [PATCH 08/26] Added changelog kiwi --- kiwi_generator/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kiwi_generator/CHANGELOG.md b/kiwi_generator/CHANGELOG.md index c7dc85a..a8090a1 100644 --- a/kiwi_generator/CHANGELOG.md +++ b/kiwi_generator/CHANGELOG.md @@ -2,6 +2,9 @@ ### Added - Nullsafety support in a dev release (the kiwi_generator code is not yet nullsafe but the generator is) +### DISCLAIMER: +- A lot of dependencies still need to do the migration. until then we will stay in a dev release + ## [2.1.1] - 2020-10-24 ### Updated - Kiwi version to 2.1.1 From 0849d431a85c30064fff0ddb691180d036067938 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Thu, 4 Mar 2021 12:22:25 +0100 Subject: [PATCH 09/26] Added changelogs --- kiwi/CHANGELOG.md | 4 ++++ kiwi_generator/CHANGELOG.md | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/kiwi/CHANGELOG.md b/kiwi/CHANGELOG.md index 80256d6..afa2de1 100644 --- a/kiwi/CHANGELOG.md +++ b/kiwi/CHANGELOG.md @@ -1,3 +1,7 @@ +## [3.0.0-nullsafety.0] - 2021-03-04 +### Added +- Nullsafety support in a dev release + ## [2.1.1] - 2020-10-24 ### Updated - Description to make the kiwi package easy to find in pub.dev diff --git a/kiwi_generator/CHANGELOG.md b/kiwi_generator/CHANGELOG.md index 73d5ebb..a8090a1 100644 --- a/kiwi_generator/CHANGELOG.md +++ b/kiwi_generator/CHANGELOG.md @@ -1,3 +1,10 @@ +## [3.0.0-nullsafety.0] - 2021-03-04 +### Added +- Nullsafety support in a dev release (the kiwi_generator code is not yet nullsafe but the generator is) + +### DISCLAIMER: +- A lot of dependencies still need to do the migration. until then we will stay in a dev release + ## [2.1.1] - 2020-10-24 ### Updated - Kiwi version to 2.1.1 From 1fe6ba1ff3fe0e2c7d05c94eb16326814cf010e9 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Thu, 4 Mar 2021 12:51:45 +0100 Subject: [PATCH 10/26] Fixed the tests --- kiwi_generator/lib/src/kiwi_injector_generator.dart | 4 +++- kiwi_generator/test/kiwi_generator_test.dart | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/kiwi_generator/lib/src/kiwi_injector_generator.dart b/kiwi_generator/lib/src/kiwi_injector_generator.dart index 549b6e7..c9ff38b 100644 --- a/kiwi_generator/lib/src/kiwi_injector_generator.dart +++ b/kiwi_generator/lib/src/kiwi_injector_generator.dart @@ -4,7 +4,6 @@ import 'package:analyzer/dart/element/type.dart'; import 'package:build/build.dart'; import 'package:code_builder/code_builder.dart'; import 'package:built_collection/built_collection.dart'; - import 'package:build/src/builder/build_step.dart'; import 'package:kiwi_generator/src/model/kiwi_generator_error.dart'; import 'package:source_gen/source_gen.dart'; @@ -143,6 +142,9 @@ class KiwiInjectorGenerator extends Generator { final DartType concrete = registerObject.getField('from').toTypeValue(); final DartType concreteType = concrete ?? type; + if (concreteType == null) { + throw KiwiGeneratorError('null can not be registered because there is no type for null'); + } final String className = concreteType.getDisplayString(withNullability: false); final String typeParameters = concrete == null diff --git a/kiwi_generator/test/kiwi_generator_test.dart b/kiwi_generator/test/kiwi_generator_test.dart index abc5023..0593307 100644 --- a/kiwi_generator/test/kiwi_generator_test.dart +++ b/kiwi_generator/test/kiwi_generator_test.dart @@ -30,7 +30,11 @@ void main() async { test('null concrete', () async { await testKiwiException( 'null_concrete_factory', - const TypeMatcher(), + const TypeMatcher().having( + (f) => f.toString(), + 'toString()', + '\nKiwiGeneratorError\n\nnull can not be registered because there is no type for null\n\n', + ), ); }); @@ -64,7 +68,11 @@ void main() async { test('null concrete', () async { await testKiwiException( 'null_concrete_singleton', - const TypeMatcher(), + const TypeMatcher().having( + (f) => f.toString(), + 'toString()', + '\nKiwiGeneratorError\n\nnull can not be registered because there is no type for null\n\n', + ), ); }); From 05e7df4d2ca8cdda6e461f417d15312ba9d4ebb3 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Thu, 4 Mar 2021 12:55:18 +0100 Subject: [PATCH 11/26] Fixed analyzer: --- kiwi_generator/lib/src/kiwi_injector_generator.dart | 3 ++- kiwi_generator/test/kiwi_generator_test.dart | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/kiwi_generator/lib/src/kiwi_injector_generator.dart b/kiwi_generator/lib/src/kiwi_injector_generator.dart index c9ff38b..ef48bbe 100644 --- a/kiwi_generator/lib/src/kiwi_injector_generator.dart +++ b/kiwi_generator/lib/src/kiwi_injector_generator.dart @@ -143,7 +143,8 @@ class KiwiInjectorGenerator extends Generator { final DartType concreteType = concrete ?? type; if (concreteType == null) { - throw KiwiGeneratorError('null can not be registered because there is no type for null'); + throw KiwiGeneratorError( + 'null can not be registered because there is no type for null'); } final String className = concreteType.getDisplayString(withNullability: false); diff --git a/kiwi_generator/test/kiwi_generator_test.dart b/kiwi_generator/test/kiwi_generator_test.dart index 0593307..31bc530 100644 --- a/kiwi_generator/test/kiwi_generator_test.dart +++ b/kiwi_generator/test/kiwi_generator_test.dart @@ -31,7 +31,7 @@ void main() async { await testKiwiException( 'null_concrete_factory', const TypeMatcher().having( - (f) => f.toString(), + (f) => f.toString(), 'toString()', '\nKiwiGeneratorError\n\nnull can not be registered because there is no type for null\n\n', ), @@ -69,7 +69,7 @@ void main() async { await testKiwiException( 'null_concrete_singleton', const TypeMatcher().having( - (f) => f.toString(), + (f) => f.toString(), 'toString()', '\nKiwiGeneratorError\n\nnull can not be registered because there is no type for null\n\n', ), From 5c194fe332156867bbfb2d6ff02237a0a1c90ac1 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Thu, 4 Mar 2021 12:58:00 +0100 Subject: [PATCH 12/26] Fixed analyzer: --- kiwi_generator/test/kiwi_generator_test.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/kiwi_generator/test/kiwi_generator_test.dart b/kiwi_generator/test/kiwi_generator_test.dart index 31bc530..0a4a65d 100644 --- a/kiwi_generator/test/kiwi_generator_test.dart +++ b/kiwi_generator/test/kiwi_generator_test.dart @@ -1,5 +1,4 @@ import 'package:kiwi_generator/src/model/kiwi_generator_error.dart'; -import 'package:source_gen/source_gen.dart'; import 'package:test/test.dart'; import 'utils/test.dart'; From 7630dce37519748dbe49182e1fff4c4e59b4180d Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Sun, 7 Mar 2021 10:46:03 +0100 Subject: [PATCH 13/26] Updated analyzer to 0.41.1 --- kiwi_generator/CHANGELOG.md | 4 ++++ kiwi_generator/pubspec.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/kiwi_generator/CHANGELOG.md b/kiwi_generator/CHANGELOG.md index a8090a1..c4caeca 100644 --- a/kiwi_generator/CHANGELOG.md +++ b/kiwi_generator/CHANGELOG.md @@ -1,3 +1,7 @@ +## [3.0.0-nullsafety.1] - 2021-03-07 +### Fixed +- Analyzer bumped to 0.41.1 + ## [3.0.0-nullsafety.0] - 2021-03-04 ### Added - Nullsafety support in a dev release (the kiwi_generator code is not yet nullsafe but the generator is) diff --git a/kiwi_generator/pubspec.yaml b/kiwi_generator/pubspec.yaml index ec9939e..9876e1f 100644 --- a/kiwi_generator/pubspec.yaml +++ b/kiwi_generator/pubspec.yaml @@ -1,13 +1,13 @@ name: kiwi_generator description: Generates dependency injection code using the kiwi package to reduce development time. -version: 3.0.0-nullsafety-generator.0 +version: 3.0.0-nullsafety-generator.7 homepage: https://github.com/vanlooverenkoen/kiwi/tree/master/kiwi_generator environment: sdk: '>=2.2.0 <3.0.0' dependencies: - analyzer: ^0.40.4 + analyzer: ^0.41.1 build: ^1.5.0 build_config: ^0.4.2 code_builder: ^3.5.0 From d1318af75fee16b33f55735dbca0fd14b8cfcd49 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Sun, 7 Mar 2021 10:50:13 +0100 Subject: [PATCH 14/26] Updated the version number --- kiwi_generator/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kiwi_generator/pubspec.yaml b/kiwi_generator/pubspec.yaml index 9876e1f..0d1a394 100644 --- a/kiwi_generator/pubspec.yaml +++ b/kiwi_generator/pubspec.yaml @@ -1,6 +1,6 @@ name: kiwi_generator description: Generates dependency injection code using the kiwi package to reduce development time. -version: 3.0.0-nullsafety-generator.7 +version: 3.0.0-nullsafety-generator.1 homepage: https://github.com/vanlooverenkoen/kiwi/tree/master/kiwi_generator environment: From 43f4d7483f00a484d17abf3e31cb6f1e59fcde6a Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Sun, 7 Mar 2021 10:51:09 +0100 Subject: [PATCH 15/26] Updated the changloge --- kiwi_generator/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kiwi_generator/CHANGELOG.md b/kiwi_generator/CHANGELOG.md index c4caeca..6cddacb 100644 --- a/kiwi_generator/CHANGELOG.md +++ b/kiwi_generator/CHANGELOG.md @@ -1,8 +1,8 @@ -## [3.0.0-nullsafety.1] - 2021-03-07 +## [3.0.0-nullsafety-generator.1] - 2021-03-07 ### Fixed - Analyzer bumped to 0.41.1 -## [3.0.0-nullsafety.0] - 2021-03-04 +## [3.0.0-nullsafety-generator.0] - 2021-03-04 ### Added - Nullsafety support in a dev release (the kiwi_generator code is not yet nullsafe but the generator is) From a7b9c20e77f17a7ac7c2fd4c0e137d6efc57bad0 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Tue, 16 Mar 2021 11:12:12 +0100 Subject: [PATCH 16/26] #51: Updated dependencies --- kiwi_generator/CHANGELOG.md | 4 +++ .../lib/src/kiwi_injector_generator.dart | 11 +++++--- kiwi_generator/pubspec.yaml | 27 ++++++++++--------- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/kiwi_generator/CHANGELOG.md b/kiwi_generator/CHANGELOG.md index 6cddacb..81a4730 100644 --- a/kiwi_generator/CHANGELOG.md +++ b/kiwi_generator/CHANGELOG.md @@ -1,3 +1,7 @@ +## [3.0.0-nullsafety-generator.2] - 2021-03-16 +### Updated dependencies +- Updated dependencies to make sure we can still build with new dependencies. + ## [3.0.0-nullsafety-generator.1] - 2021-03-07 ### Fixed - Analyzer bumped to 0.41.1 diff --git a/kiwi_generator/lib/src/kiwi_injector_generator.dart b/kiwi_generator/lib/src/kiwi_injector_generator.dart index ef48bbe..5117fa9 100644 --- a/kiwi_generator/lib/src/kiwi_injector_generator.dart +++ b/kiwi_generator/lib/src/kiwi_injector_generator.dart @@ -141,7 +141,6 @@ class KiwiInjectorGenerator extends Generator { final DartType type = registerObject.getField('type').toTypeValue(); final DartType concrete = registerObject.getField('from').toTypeValue(); final DartType concreteType = concrete ?? type; - if (concreteType == null) { throw KiwiGeneratorError( 'null can not be registered because there is no type for null'); @@ -201,8 +200,14 @@ class KiwiInjectorGenerator extends Generator { ParameterElement parameter, Map resolvers, ) { - final String name = resolvers == null ? null : resolvers[parameter.type]; - final String nameArgument = name == null ? '' : "'$name'"; + final List dartTypes = resolvers == null + ? [] + : resolvers.keys + .where((element) => + element.getDisplayString(withNullability: false) == + parameter.type.getDisplayString(withNullability: false)) + .toList(); + final String nameArgument = dartTypes.isEmpty ? '' : "'${resolvers[dartTypes.first]}'"; return '${parameter.isNamed ? parameter.name + ': ' : ''}c<${parameter.type.getDisplayString(withNullability: false)}>($nameArgument)'; } diff --git a/kiwi_generator/pubspec.yaml b/kiwi_generator/pubspec.yaml index 0d1a394..6f195b5 100644 --- a/kiwi_generator/pubspec.yaml +++ b/kiwi_generator/pubspec.yaml @@ -1,23 +1,24 @@ name: kiwi_generator description: Generates dependency injection code using the kiwi package to reduce development time. -version: 3.0.0-nullsafety-generator.1 +version: 3.0.0-nullsafety-generator.2 homepage: https://github.com/vanlooverenkoen/kiwi/tree/master/kiwi_generator environment: - sdk: '>=2.2.0 <3.0.0' + # Keeping this <2.12.0 because the code is not null safe – yet! + sdk: '>=2.11.99 <3.0.0' dependencies: - analyzer: ^0.41.1 - build: ^1.5.0 - build_config: ^0.4.2 - code_builder: ^3.5.0 - dart_style: ^1.3.8 + analyzer: ^1.2.0 + build: ^2.0.0 + build_config: ^0.4.7 + code_builder: ^3.7.0 + dart_style: ^1.3.14 kiwi: ^3.0.0-nullsafety.0 - path: ^1.7.0 - source_gen: ^0.9.7+1 - built_collection: ^4.3.2 + path: ^1.8.0 + source_gen: ^0.9.10+4 + built_collection: ^5.0.0 dev_dependencies: - build_runner: ^1.10.3 - build_test: ^1.2.2 - test: ^1.15.4 + build_runner: ^1.12.1 + build_test: ^2.0.0 + test: ^1.16.8 From 8245c6ba154af99d2c5fd2e3036df4d3c97b4eac Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Tue, 16 Mar 2021 11:22:29 +0100 Subject: [PATCH 17/26] Fixed formatting --- kiwi_generator/lib/src/kiwi_injector_generator.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kiwi_generator/lib/src/kiwi_injector_generator.dart b/kiwi_generator/lib/src/kiwi_injector_generator.dart index 5117fa9..15b92e4 100644 --- a/kiwi_generator/lib/src/kiwi_injector_generator.dart +++ b/kiwi_generator/lib/src/kiwi_injector_generator.dart @@ -207,7 +207,8 @@ class KiwiInjectorGenerator extends Generator { element.getDisplayString(withNullability: false) == parameter.type.getDisplayString(withNullability: false)) .toList(); - final String nameArgument = dartTypes.isEmpty ? '' : "'${resolvers[dartTypes.first]}'"; + final String nameArgument = + dartTypes.isEmpty ? '' : "'${resolvers[dartTypes.first]}'"; return '${parameter.isNamed ? parameter.name + ': ' : ''}c<${parameter.type.getDisplayString(withNullability: false)}>($nameArgument)'; } From e1a33168f6c6536dceef3d87bd60ba004774d443 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Tue, 16 Mar 2021 14:02:12 +0100 Subject: [PATCH 18/26] Version bump --- kiwi_generator/CHANGELOG.md | 5 +++++ kiwi_generator/pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/kiwi_generator/CHANGELOG.md b/kiwi_generator/CHANGELOG.md index 81a4730..bbc7b97 100644 --- a/kiwi_generator/CHANGELOG.md +++ b/kiwi_generator/CHANGELOG.md @@ -1,3 +1,8 @@ +## [3.0.0-nullsafety-generator.3] - 2021-03-16 +### Updated dependencies +- Updated dependencies to make sure we can still build with new dependencies. + + ## [3.0.0-nullsafety-generator.2] - 2021-03-16 ### Updated dependencies - Updated dependencies to make sure we can still build with new dependencies. diff --git a/kiwi_generator/pubspec.yaml b/kiwi_generator/pubspec.yaml index 6f195b5..1d22548 100644 --- a/kiwi_generator/pubspec.yaml +++ b/kiwi_generator/pubspec.yaml @@ -1,6 +1,6 @@ name: kiwi_generator description: Generates dependency injection code using the kiwi package to reduce development time. -version: 3.0.0-nullsafety-generator.2 +version: 3.0.0-nullsafety-generator.3 homepage: https://github.com/vanlooverenkoen/kiwi/tree/master/kiwi_generator environment: From 8bd46aba38acc262da8c985679a3bb9f39a060a3 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Fri, 19 Mar 2021 18:32:53 +0100 Subject: [PATCH 19/26] #51 Updated dependencies. & fixed a breaking issue with the kiwi container resolve --- kiwi/CHANGELOG.md | 4 ++++ kiwi/lib/src/kiwi_container.dart | 3 ++- kiwi/pubspec.yaml | 4 ++-- kiwi_generator/pubspec.yaml | 6 +++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/kiwi/CHANGELOG.md b/kiwi/CHANGELOG.md index afa2de1..65993d0 100644 --- a/kiwi/CHANGELOG.md +++ b/kiwi/CHANGELOG.md @@ -1,3 +1,7 @@ +## [3.0.0-nullsafety.1] - 2021-03-19 +### Breaking +- resolve should not be nullable. + ## [3.0.0-nullsafety.0] - 2021-03-04 ### Added - Nullsafety support in a dev release diff --git a/kiwi/lib/src/kiwi_container.dart b/kiwi/lib/src/kiwi_container.dart index 98b285d..3419597 100644 --- a/kiwi/lib/src/kiwi_container.dart +++ b/kiwi/lib/src/kiwi_container.dart @@ -125,7 +125,8 @@ class KiwiContainer { 'Failed to resolve `$S` as `$T`:\n\nThe type `$S` as `$T` was not registered${name == null ? '' : ' for the name `$name`'}\n\nMake sure `$T` is added to your KiwiContainer and rerun build_runner build\n(If you are using the kiwi_generator)\n\nWhen using Flutter, most of the time a hot restart is required to setup the KiwiContainer again.'); } if (obj == null) return null; - return obj as T; + if (obj is T) return obj as T; + return null; } T call([String? name]) => resolve(name); diff --git a/kiwi/pubspec.yaml b/kiwi/pubspec.yaml index d869e2a..ee8203c 100644 --- a/kiwi/pubspec.yaml +++ b/kiwi/pubspec.yaml @@ -1,6 +1,6 @@ name: kiwi description: A simple yet efficient dependency injection container for Dart and Flutter (can be coupled with the kiwi_generator package). -version: 3.0.0-nullsafety.0 +version: 3.0.0-nullsafety.1 homepage: https://github.com/vanlooverenkoen/kiwi/tree/master/kiwi environment: @@ -10,4 +10,4 @@ dependencies: meta: ^1.3.0 dev_dependencies: - test: ^1.16.5 + test: ^1.16.8 diff --git a/kiwi_generator/pubspec.yaml b/kiwi_generator/pubspec.yaml index 55bc4e2..49972be 100644 --- a/kiwi_generator/pubspec.yaml +++ b/kiwi_generator/pubspec.yaml @@ -12,14 +12,14 @@ dependencies: build: ^2.0.0 build_config: ^0.4.7 code_builder: ^3.7.0 - dart_style: ^1.3.14 + dart_style: ^2.0.0 kiwi: ^3.0.0-nullsafety.0 path: ^1.8.0 - source_gen: ^0.9.10+4 + source_gen: ^1.0.0 built_collection: ^5.0.0 dev_dependencies: - build_runner: ^1.12.1 + build_runner: ^1.12.2 build_test: ^2.0.0 test: ^1.16.8 From 976289a939e97bbaadbe64252c59751418e206d0 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Fri, 19 Mar 2021 18:34:59 +0100 Subject: [PATCH 20/26] Version bumps --- kiwi_generator/CHANGELOG.md | 6 +++++- kiwi_generator/pubspec.yaml | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/kiwi_generator/CHANGELOG.md b/kiwi_generator/CHANGELOG.md index 779d852..ba6fcfb 100644 --- a/kiwi_generator/CHANGELOG.md +++ b/kiwi_generator/CHANGELOG.md @@ -1,9 +1,13 @@ -## [3.0.0-nullsafety-generator.3] - 2021-03-16 +## [3.0.0-nullsafety-generator.4] - 2021-03-16 ### Added - Nullsafety codebase migration ### Updated dependencies - Updated dependencies to make sure we can still build with new dependencies. +## [3.0.0-nullsafety-generator.3] - 2021-03-16 +### Updated dependencies +- Updated dependencies to make sure we can still build with new dependencies. + ## [3.0.0-nullsafety-generator.2] - 2021-03-16 ### Updated dependencies - Updated dependencies to make sure we can still build with new dependencies. diff --git a/kiwi_generator/pubspec.yaml b/kiwi_generator/pubspec.yaml index 49972be..c17e652 100644 --- a/kiwi_generator/pubspec.yaml +++ b/kiwi_generator/pubspec.yaml @@ -1,6 +1,6 @@ name: kiwi_generator description: Generates dependency injection code using the kiwi package to reduce development time. -version: 3.0.0-nullsafety-generator.3 +version: 3.0.0-nullsafety-generator.4 homepage: https://github.com/vanlooverenkoen/kiwi/tree/master/kiwi_generator environment: @@ -13,7 +13,7 @@ dependencies: build_config: ^0.4.7 code_builder: ^3.7.0 dart_style: ^2.0.0 - kiwi: ^3.0.0-nullsafety.0 + kiwi: ^3.0.0-nullsafety.1 path: ^1.8.0 source_gen: ^1.0.0 built_collection: ^5.0.0 From 4bc38549de31da82e709be3146dbf34e694ae350 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Fri, 19 Mar 2021 18:36:20 +0100 Subject: [PATCH 21/26] Updated dependencies --- kiwi_generator/CHANGELOG.md | 7 ++++++- kiwi_generator/pubspec.yaml | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/kiwi_generator/CHANGELOG.md b/kiwi_generator/CHANGELOG.md index bbc7b97..ba6fcfb 100644 --- a/kiwi_generator/CHANGELOG.md +++ b/kiwi_generator/CHANGELOG.md @@ -1,7 +1,12 @@ -## [3.0.0-nullsafety-generator.3] - 2021-03-16 +## [3.0.0-nullsafety-generator.4] - 2021-03-16 +### Added +- Nullsafety codebase migration ### Updated dependencies - Updated dependencies to make sure we can still build with new dependencies. +## [3.0.0-nullsafety-generator.3] - 2021-03-16 +### Updated dependencies +- Updated dependencies to make sure we can still build with new dependencies. ## [3.0.0-nullsafety-generator.2] - 2021-03-16 ### Updated dependencies diff --git a/kiwi_generator/pubspec.yaml b/kiwi_generator/pubspec.yaml index 1d22548..ecb4e36 100644 --- a/kiwi_generator/pubspec.yaml +++ b/kiwi_generator/pubspec.yaml @@ -1,13 +1,13 @@ name: kiwi_generator description: Generates dependency injection code using the kiwi package to reduce development time. -version: 3.0.0-nullsafety-generator.3 +version: 3.0.0-nullsafety-generator.4 homepage: https://github.com/vanlooverenkoen/kiwi/tree/master/kiwi_generator environment: # Keeping this <2.12.0 because the code is not null safe – yet! sdk: '>=2.11.99 <3.0.0' -dependencies: +dependencies: analyzer: ^1.2.0 build: ^2.0.0 build_config: ^0.4.7 From 86acb45c6ad4ca44c59f626c9a5c656445227e21 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Fri, 19 Mar 2021 18:37:23 +0100 Subject: [PATCH 22/26] Updated the versions to match the nullsafe codebase --- kiwi_generator/pubspec.yaml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/kiwi_generator/pubspec.yaml b/kiwi_generator/pubspec.yaml index ecb4e36..96cae26 100644 --- a/kiwi_generator/pubspec.yaml +++ b/kiwi_generator/pubspec.yaml @@ -12,13 +12,17 @@ dependencies: build: ^2.0.0 build_config: ^0.4.7 code_builder: ^3.7.0 - dart_style: ^1.3.14 - kiwi: ^3.0.0-nullsafety.0 + dart_style: ^2.0.0 + kiwi: ^3.0.0-nullsafety.1 path: ^1.8.0 - source_gen: ^0.9.10+4 + source_gen: ^1.0.0 built_collection: ^5.0.0 dev_dependencies: - build_runner: ^1.12.1 + build_runner: ^1.12.2 build_test: ^2.0.0 test: ^1.16.8 + +dependency_overrides: + kiwi: + path: ../kiwi \ No newline at end of file From 73b20b7d7ee89361c5d0e1783a385e159c31b6ff Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Tue, 1 Jun 2021 18:16:17 +0200 Subject: [PATCH 23/26] #51: Updated all latest versions to fully support nullsafety --- example/pubspec.yaml | 10 ++++---- flutter_example/lib/widget/error_widget.dart | 4 +++- flutter_example/pubspec.yaml | 8 +++---- kiwi/pubspec.yaml | 4 ++-- .../lib/src/kiwi_injector_generator.dart | 2 +- .../lib/src/model/kiwi_generator_error.dart | 8 ++++--- kiwi_generator/pubspec.yaml | 23 +++++++++---------- 7 files changed, 31 insertions(+), 28 deletions(-) diff --git a/example/pubspec.yaml b/example/pubspec.yaml index b7d2096..eb74cd9 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -4,15 +4,15 @@ version: 0.1.0 homepage: https://github.com/vanlooverenkoen/kiwi environment: - sdk: '>=2.0.0 <3.0.0' + sdk: '>=2.12.0 <3.0.0' dependencies: - kiwi: ^2.1.1 + kiwi: ^3.0.0 dev_dependencies: - test: ^1.15.4 - build_runner: ^1.10.3 - kiwi_generator: ^2.1.1 + test: ^1.17.5 + build_runner: ^2.0.4 + kiwi_generator: ^3.0.0 dependency_overrides: kiwi: diff --git a/flutter_example/lib/widget/error_widget.dart b/flutter_example/lib/widget/error_widget.dart index 0a054e1..7fe04d5 100644 --- a/flutter_example/lib/widget/error_widget.dart +++ b/flutter_example/lib/widget/error_widget.dart @@ -3,7 +3,9 @@ import 'package:flutter/material.dart'; class ErrorContainer extends StatelessWidget { final VoidCallback error; - const ErrorContainer({@required this.error}); + const ErrorContainer({ + required this.error, + }); @override Widget build(BuildContext context) { diff --git a/flutter_example/pubspec.yaml b/flutter_example/pubspec.yaml index 77c47fa..117cd04 100644 --- a/flutter_example/pubspec.yaml +++ b/flutter_example/pubspec.yaml @@ -3,18 +3,18 @@ description: A Flutter example for kiwi version: 1.0.0+1 environment: - sdk: ">=2.2.0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: flutter: sdk: flutter - kiwi: ^2.1.1 + kiwi: ^3.0.0 dev_dependencies: flutter_test: sdk: flutter - build_runner: ^1.11.5 - kiwi_generator: ^2.1.1 + build_runner: ^2.0.4 + kiwi_generator: ^3.0.0 dependency_overrides: kiwi: diff --git a/kiwi/pubspec.yaml b/kiwi/pubspec.yaml index ee8203c..ea603ac 100644 --- a/kiwi/pubspec.yaml +++ b/kiwi/pubspec.yaml @@ -1,6 +1,6 @@ name: kiwi description: A simple yet efficient dependency injection container for Dart and Flutter (can be coupled with the kiwi_generator package). -version: 3.0.0-nullsafety.1 +version: 3.0.0 homepage: https://github.com/vanlooverenkoen/kiwi/tree/master/kiwi environment: @@ -10,4 +10,4 @@ dependencies: meta: ^1.3.0 dev_dependencies: - test: ^1.16.8 + test: ^1.17.5 diff --git a/kiwi_generator/lib/src/kiwi_injector_generator.dart b/kiwi_generator/lib/src/kiwi_injector_generator.dart index 4604498..42fea50 100644 --- a/kiwi_generator/lib/src/kiwi_injector_generator.dart +++ b/kiwi_generator/lib/src/kiwi_injector_generator.dart @@ -42,7 +42,7 @@ class KiwiInjectorGenerator extends Generator { ..body.addAll( injectors.map((i) => _generateInjector(i, library, buildStep)))); - final DartEmitter emitter = DartEmitter(Allocator()); + final DartEmitter emitter = DartEmitter(allocator: Allocator()); return DartFormatter().format('${file.accept(emitter)}'); } catch (e) { if (e is KiwiGeneratorError || e is UnresolvedAnnotationException) { diff --git a/kiwi_generator/lib/src/model/kiwi_generator_error.dart b/kiwi_generator/lib/src/model/kiwi_generator_error.dart index c0286f1..6f0140f 100644 --- a/kiwi_generator/lib/src/model/kiwi_generator_error.dart +++ b/kiwi_generator/lib/src/model/kiwi_generator_error.dart @@ -2,15 +2,17 @@ class KiwiGeneratorError extends Error { final String message; final Error? error; - KiwiGeneratorError(this.message, {this.error}); + KiwiGeneratorError( + this.message, { + this.error, + }); @override String toString() { var toString = '\nKiwiGeneratorError\n\n$message\n\n'; final internalError = error; if (internalError != null) { - toString += - '============\n${internalError.toString()}\n${internalError.stackTrace}\n============\n\n'; + toString += '============\n${internalError.toString()}\n${internalError.stackTrace}\n============\n\n'; } return toString; } diff --git a/kiwi_generator/pubspec.yaml b/kiwi_generator/pubspec.yaml index c17e652..8d1e76a 100644 --- a/kiwi_generator/pubspec.yaml +++ b/kiwi_generator/pubspec.yaml @@ -1,27 +1,26 @@ name: kiwi_generator description: Generates dependency injection code using the kiwi package to reduce development time. -version: 3.0.0-nullsafety-generator.4 +version: 3.0.0 homepage: https://github.com/vanlooverenkoen/kiwi/tree/master/kiwi_generator environment: - # Keeping this <2.12.0 because the code is not null safe – yet! sdk: '>=2.12.0 <3.0.0' dependencies: - analyzer: ^1.2.0 - build: ^2.0.0 - build_config: ^0.4.7 - code_builder: ^3.7.0 - dart_style: ^2.0.0 - kiwi: ^3.0.0-nullsafety.1 + analyzer: ^1.7.1 + build: ^2.0.2 + build_config: ^1.0.0 + code_builder: ^4.0.0 + dart_style: ^2.0.1 + kiwi: ^3.0.0 path: ^1.8.0 - source_gen: ^1.0.0 + source_gen: ^1.0.1 built_collection: ^5.0.0 dev_dependencies: - build_runner: ^1.12.2 - build_test: ^2.0.0 - test: ^1.16.8 + build_runner: ^2.0.4 + build_test: ^2.1.0 + test: ^1.17.5 dependency_overrides: kiwi: From d9a7a95fc3463aeb29763425a343ab2921ba0c28 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Tue, 1 Jun 2021 18:25:44 +0200 Subject: [PATCH 24/26] Fixed formatter --- kiwi_generator/lib/src/model/kiwi_generator_error.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kiwi_generator/lib/src/model/kiwi_generator_error.dart b/kiwi_generator/lib/src/model/kiwi_generator_error.dart index 6f0140f..5d12461 100644 --- a/kiwi_generator/lib/src/model/kiwi_generator_error.dart +++ b/kiwi_generator/lib/src/model/kiwi_generator_error.dart @@ -12,7 +12,8 @@ class KiwiGeneratorError extends Error { var toString = '\nKiwiGeneratorError\n\n$message\n\n'; final internalError = error; if (internalError != null) { - toString += '============\n${internalError.toString()}\n${internalError.stackTrace}\n============\n\n'; + toString += + '============\n${internalError.toString()}\n${internalError.stackTrace}\n============\n\n'; } return toString; } From b784a1b5af29e112ceb04108c99e96314a000575 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Tue, 1 Jun 2021 18:53:20 +0200 Subject: [PATCH 25/26] #51: Fixed tests --- kiwi/lib/src/kiwi_container.dart | 7 +-- .../model/exception/not_registered_error.dart | 10 ++++ kiwi/test/kiwi_test.dart | 48 +++++++++++++++---- 3 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 kiwi/lib/src/model/exception/not_registered_error.dart diff --git a/kiwi/lib/src/kiwi_container.dart b/kiwi/lib/src/kiwi_container.dart index 3419597..dceb112 100644 --- a/kiwi/lib/src/kiwi_container.dart +++ b/kiwi/lib/src/kiwi_container.dart @@ -1,4 +1,5 @@ import 'package:kiwi/src/model/exception/kiwi_error.dart'; +import 'package:kiwi/src/model/exception/not_registered_error.dart'; import 'package:meta/meta.dart'; /// Signature for a builder which creates an object of type [T]. @@ -91,17 +92,17 @@ class KiwiContainer { T resolve([String? name]) { final providers = _namedProviders[name] ?? Map>(); if (!silent && !(providers.containsKey(T))) { - throw KiwiError( + throw NotRegisteredKiwiError( 'Failed to resolve `$T`:\n\nThe type `$T` was not registered${name == null ? '' : ' for the name `$name`'}\n\nMake sure `$T` is added to your KiwiContainer and rerun build_runner build\n(If you are using the kiwi_generator)\n\nWhen using Flutter, most of the time a hot restart is required to setup the KiwiContainer again.'); } final value = providers[T]?.get(this); if (value == null) { - throw KiwiError( + throw NotRegisteredKiwiError( 'Failed to resolve `$T`:\n\nThe type `$T` was not registered${name == null ? '' : ' for the name `$name`'}\n\nMake sure `$T` is added to your KiwiContainer and rerun build_runner build\n(If you are using the kiwi_generator)\n\nWhen using Flutter, most of the time a hot restart is required to setup the KiwiContainer again.'); } if (value is T) return value as T; - throw KiwiError( + throw NotRegisteredKiwiError( 'Failed to resolve `$T`:\n\nValue was not registered as `$T`\n\nThe type `$T` was not registered${name == null ? '' : ' for the name `$name`'}\n\nMake sure `$T` is added to your KiwiContainer and rerun build_runner build\n(If you are using the kiwi_generator)\n\nWhen using Flutter, most of the time a hot restart is required to setup the KiwiContainer again.'); } diff --git a/kiwi/lib/src/model/exception/not_registered_error.dart b/kiwi/lib/src/model/exception/not_registered_error.dart new file mode 100644 index 0000000..dd703d8 --- /dev/null +++ b/kiwi/lib/src/model/exception/not_registered_error.dart @@ -0,0 +1,10 @@ +import 'package:kiwi/src/model/exception/kiwi_error.dart'; + +class NotRegisteredKiwiError extends KiwiError { + NotRegisteredKiwiError(String message) : super(message); + + @override + String toString() { + return 'Not Registered KiwiError:\n\n\n$message\n\n\n'; + } +} diff --git a/kiwi/test/kiwi_test.dart b/kiwi/test/kiwi_test.dart index 1a788db..b10635a 100644 --- a/kiwi/test/kiwi_test.dart +++ b/kiwi/test/kiwi_test.dart @@ -1,5 +1,6 @@ import 'package:kiwi/kiwi.dart'; import 'package:kiwi/src/model/exception/kiwi_error.dart'; +import 'package:kiwi/src/model/exception/not_registered_error.dart'; import 'package:test/test.dart'; void main() { @@ -40,8 +41,14 @@ void main() { expect(container.resolve(), 5); expect(container.resolve('named'), 6); expect(container.resolve(), 7); - expect(container.resolve('named'), null); - expect(container.resolve(), person); + + expect( + () => container.resolve('named'), + throwsA(TypeMatcher().having( + (f) => f.toString(), + 'toString()', + 'Not Registered KiwiError:\n\n\nFailed to resolve `num`:\n\nThe type `num` was not registered for the name `named`\n\nMake sure `num` is added to your KiwiContainer and rerun build_runner build\n(If you are using the kiwi_generator)\n\nWhen using Flutter, most of the time a hot restart is required to setup the KiwiContainer again.\n\n\n', + ))); }); test('instances should be resolveAs', () { @@ -49,7 +56,14 @@ void main() { container.registerSingleton((c) => sith); expect(container.resolveAs(), sith); - expect(container.resolveAs('named'), null); + + expect( + () => container.resolveAs('named'), + throwsA(TypeMatcher().having( + (f) => f.toString(), + 'toString()', + 'Not Registered KiwiError:\n\n\nFailed to resolve `Character`:\n\nThe type `Character` was not registered for the name `named`\n\nMake sure `Character` is added to your KiwiContainer and rerun build_runner build\n(If you are using the kiwi_generator)\n\nWhen using Flutter, most of the time a hot restart is required to setup the KiwiContainer again.\n\n\n', + ))); }); test('container should resolve when called', () { @@ -62,7 +76,13 @@ void main() { expect(container(), 5); expect(container('named'), 6); expect(container(), 7); - expect(container('named'), null); + expect( + () => container.resolve('named'), + throwsA(TypeMatcher().having( + (f) => f.toString(), + 'toString()', + 'Not Registered KiwiError:\n\n\nFailed to resolve `num`:\n\nThe type `num` was not registered for the name `named`\n\nMake sure `num` is added to your KiwiContainer and rerun build_runner build\n(If you are using the kiwi_generator)\n\nWhen using Flutter, most of the time a hot restart is required to setup the KiwiContainer again.\n\n\n', + ))); expect(container(), person); }); @@ -127,10 +147,22 @@ void main() { expect(container.resolve('named'), 6); container.unregister(); - expect(container.resolve(), null); + expect( + () => container.resolve(), + throwsA(TypeMatcher().having( + (f) => f.toString(), + 'toString()', + 'Not Registered KiwiError:\n\n\nFailed to resolve `int`:\n\nThe type `int` was not registered\n\nMake sure `int` is added to your KiwiContainer and rerun build_runner build\n(If you are using the kiwi_generator)\n\nWhen using Flutter, most of the time a hot restart is required to setup the KiwiContainer again.\n\n\n', + ))); container.unregister('named'); - expect(container.resolve('named'), null); + expect( + () => container.resolve('named'), + throwsA(TypeMatcher().having( + (f) => f.toString(), + 'toString()', + 'Not Registered KiwiError:\n\n\nFailed to resolve `int`:\n\nThe type `int` was not registered for the name `named`\n\nMake sure `int` is added to your KiwiContainer and rerun build_runner build\n(If you are using the kiwi_generator)\n\nWhen using Flutter, most of the time a hot restart is required to setup the KiwiContainer again.\n\n\n', + ))); }); }); @@ -188,7 +220,7 @@ void main() { throwsA(TypeMatcher().having( (f) => f.toString(), 'toString()', - 'KiwiError:\n\n\nFailed to resolve `int`:\n\nThe type `int` was not registered\n\nMake sure `int` is added to your KiwiContainer and rerun build_runner build\n(If you are using the kiwi_generator)\n\nWhen using Flutter, most of the time a hot restart is required to setup the KiwiContainer again.\n\n\n', + 'Not Registered KiwiError:\n\n\nFailed to resolve `int`:\n\nThe type `int` was not registered\n\nMake sure `int` is added to your KiwiContainer and rerun build_runner build\n(If you are using the kiwi_generator)\n\nWhen using Flutter, most of the time a hot restart is required to setup the KiwiContainer again.\n\n\n', ))); expect( @@ -196,7 +228,7 @@ void main() { throwsA(TypeMatcher().having( (f) => f.toString(), 'toString()', - 'KiwiError:\n\n\nFailed to resolve `int`:\n\nThe type `int` was not registered for the name `name`\n\nMake sure `int` is added to your KiwiContainer and rerun build_runner build\n(If you are using the kiwi_generator)\n\nWhen using Flutter, most of the time a hot restart is required to setup the KiwiContainer again.\n\n\n', + 'Not Registered KiwiError:\n\n\nFailed to resolve `int`:\n\nThe type `int` was not registered for the name `name`\n\nMake sure `int` is added to your KiwiContainer and rerun build_runner build\n(If you are using the kiwi_generator)\n\nWhen using Flutter, most of the time a hot restart is required to setup the KiwiContainer again.\n\n\n', ))); }); test('values should exist when resolving as', () { From 5f994fd9d88dbde257208f45cb2688cf7730c02d Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Tue, 1 Jun 2021 18:59:16 +0200 Subject: [PATCH 26/26] Fixed analyser --- kiwi/test/kiwi_test.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/kiwi/test/kiwi_test.dart b/kiwi/test/kiwi_test.dart index b10635a..3a21b2b 100644 --- a/kiwi/test/kiwi_test.dart +++ b/kiwi/test/kiwi_test.dart @@ -1,6 +1,5 @@ import 'package:kiwi/kiwi.dart'; import 'package:kiwi/src/model/exception/kiwi_error.dart'; -import 'package:kiwi/src/model/exception/not_registered_error.dart'; import 'package:test/test.dart'; void main() {