diff --git a/lib/get_it_impl.dart b/lib/get_it_impl.dart index 66618b4..b1ea2c3 100644 --- a/lib/get_it_impl.dart +++ b/lib/get_it_impl.dart @@ -790,7 +790,7 @@ class _GetItImplementation implements GetIt { for (final type in dependsOn!) { final dependentFactory = - _findFirstFactoryByNameAndTypeOrNull(instanceName, type); + _findFirstFactoryByNameAndTypeOrNull(null, type); throwIf(dependentFactory == null, ArgumentError('Dependent Type $type is not registered in GetIt')); throwIfNot( diff --git a/pubspec.yaml b/pubspec.yaml index 2e6b040..0c2b210 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: get_it description: Simple direct Service Locator that allows to decouple the interface from a concrete implementation and to access the concrete implementation from everywhere in your App" -version: 6.1.1 +version: 6.1.2 maintainer: Thomas Burkhart (@escamoteur) authors: - Flutter Community diff --git a/test/async_test.dart b/test/async_test.dart index e4fd265..97cbbfc 100644 --- a/test/async_test.dart +++ b/test/async_test.dart @@ -656,6 +656,22 @@ void main() { expect(instance, const TypeMatcher()); }); + test('Register singleton with dependency and instanceName', () async { + final getIt = GetIt.instance; + await getIt.reset(); + getIt.registerSingletonAsync( + () async => TestClass(internalCompletion: false), + ); + + getIt.registerSingletonAsync( + () async => TestClass2(internalCompletion: false), + instanceName: "test2InstanceName", + dependsOn: [TestClass]); + + await getIt.allReady(); + expect(getIt.get(instanceName: "test2InstanceName"), isA()); + }); + test('Code for ReadMe', () async { final sl = GetIt.instance;