File tree Expand file tree Collapse file tree 7 files changed +16
-10
lines changed
modular_interfaces/lib/src/di Expand file tree Collapse file tree 7 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import '../../shared/either.dart';
66abstract class ModuleService {
77 Either <ModularError , Unit > start (RouteContext module);
88 Either <ModularError , Unit > bind (BindContext module);
9- Either <ModularError , Unit > unbind <T extends BindContext >();
9+ Either <ModularError , Unit > unbind <T extends BindContext >({ Type ? type} );
1010 Either <ModularError , Unit > finish ();
1111 Future <Either <ModularError , bool >> isModuleReady <M extends Module >();
1212}
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import '../../shared/either.dart';
33import '../services/module_service.dart' ;
44
55abstract class UnbindModule {
6- Either <ModularError , Unit > call <T extends BindContext >();
6+ Either <ModularError , Unit > call <T extends BindContext >({ Type ? type} );
77}
88
99class UnbindModuleImpl implements UnbindModule {
@@ -12,7 +12,7 @@ class UnbindModuleImpl implements UnbindModule {
1212 UnbindModuleImpl (this .moduleService);
1313
1414 @override
15- Either <ModularError , Unit > call <T extends BindContext >() {
16- return moduleService.unbind <T >();
15+ Either <ModularError , Unit > call <T extends BindContext >({ Type ? type} ) {
16+ return moduleService.unbind <T >(type : type );
1717 }
1818}
Original file line number Diff line number Diff line change @@ -32,8 +32,8 @@ class ModuleServiceImpl extends ModuleService {
3232 }
3333
3434 @override
35- Either <ModularError , Unit > unbind <T extends BindContext >() {
36- tracker.injector.removeBindContext <T >();
35+ Either <ModularError , Unit > unbind <T extends BindContext >({ Type ? type} ) {
36+ tracker.injector.removeBindContext <T >(type : type );
3737 return right (unit);
3838 }
3939}
Original file line number Diff line number Diff line change @@ -110,6 +110,6 @@ class _ModularProviderState<T extends BindContext>
110110 @override
111111 void dispose () {
112112 super .dispose ();
113- injector.get <UnbindModule >().call <T >();
113+ injector.get <UnbindModule >().call <T >(type : widget.module.runtimeType );
114114 }
115115}
Original file line number Diff line number Diff line change @@ -13,6 +13,12 @@ dependencies:
1313 flutter :
1414 sdk : flutter
1515
16+ dependency_overrides :
17+ modular_core :
18+ path : ../modular_core
19+ modular_interfaces :
20+ path : ../modular_interfaces
21+
1622dev_dependencies :
1723 flutter_lints : ^1.0.4
1824 mocktail : ^0.1.4
Original file line number Diff line number Diff line change @@ -134,8 +134,8 @@ class InjectorImpl<T> extends Injector<T> {
134134
135135 @override
136136 @mustCallSuper
137- void removeBindContext <B extends BindContext >() {
138- final module = _allBindContexts.remove (_getType <B >());
137+ void removeBindContext <B extends BindContext >({ Type ? type} ) {
138+ final module = _allBindContexts.remove (type ?? _getType <B >());
139139 if (module != null ) {
140140 module.dispose ();
141141 debugPrint ("-- ${module .runtimeType } DISPOSED" );
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ abstract class Injector<T> {
3030 void destroy ();
3131
3232 /// remove [BindContext] by [Type]
33- void removeBindContext <B extends BindContext >();
33+ void removeBindContext <T extends BindContext >({ Type ? type} );
3434
3535 /// checks if all asynchronous binds are ready to be used synchronously of all BindContext of Tree.
3636 Future <bool > isModuleReady <M extends BindContext >();
You can’t perform that action at this time.
0 commit comments