File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -1057,7 +1057,7 @@ class _GetItImplementation implements GetIt {
1057
1057
}
1058
1058
1059
1059
final typeRegistration = registrationScope.typeRegistrations
1060
- .putIfAbsent (T , () => _TypeRegistration ());
1060
+ .putIfAbsent (T , () => _TypeRegistration < T > ());
1061
1061
1062
1062
final serviceFactory = _ServiceFactory <T , P1 , P2 >(
1063
1063
this ,
Original file line number Diff line number Diff line change @@ -402,6 +402,31 @@ void main() {
402
402
GetIt .I .reset ();
403
403
});
404
404
405
+ test ('get all registered instances of the same type' , () {
406
+ final getIt = GetIt .instance;
407
+ GetIt .allowRegisterMultipleImplementationsOfoneType = true ;
408
+ constructorCounter = 0 ;
409
+
410
+ getIt.registerLazySingleton <TestBaseClass >(
411
+ () => TestClass (),
412
+ );
413
+ getIt.registerLazySingleton <TestBaseClass >(
414
+ () => TestClass (),
415
+ );
416
+
417
+ expect (constructorCounter, 0 );
418
+
419
+ final Iterable <TestBaseClass > instances = getIt.getAll <TestBaseClass >();
420
+
421
+ expect (instances.length, 2 );
422
+ expect (instances.first is TestClass , true );
423
+ expect (instances.last is TestClass , true );
424
+ expect (constructorCounter, 2 );
425
+
426
+ GetIt .I .reset ();
427
+ GetIt .allowRegisterMultipleImplementationsOfoneType = false ;
428
+ });
429
+
405
430
test ('reset lazy Singleton when the disposing function is a future' ,
406
431
() async {
407
432
final getIt = GetIt .instance;
You can’t perform that action at this time.
0 commit comments