diff --git a/flutter_modular/CHANGELOG.md b/flutter_modular/CHANGELOG.md index 89df2e99..f617dbeb 100644 --- a/flutter_modular/CHANGELOG.md +++ b/flutter_modular/CHANGELOG.md @@ -1,3 +1,12 @@ +## [6.3.0] - 2023-08-31 +- Fix phantom dependencies. + When an instance was registered in an ancestor Module, it was available to its children + automatically. This created comprehension issues when the module was separated from the base app. + Now we recommend creating a global Module, exporting the binds and importing them into the modules. + +## [6.1.1] - 2023-08-8 +- Fix Exported Dependencies + ## [6.1.0+1] - 2023-08-24 - Add: Register and get with keys: diff --git a/flutter_modular/pubspec.yaml b/flutter_modular/pubspec.yaml index feb5681d..3364c7d1 100644 --- a/flutter_modular/pubspec.yaml +++ b/flutter_modular/pubspec.yaml @@ -1,13 +1,13 @@ name: flutter_modular description: Smart project structure with dependency injection and route management -version: 6.1.0+1 +version: 6.3.0 homepage: https://github.com/Flutterando/modular environment: sdk: ">=3.0.0 <4.0.0" dependencies: - modular_core: ">=3.1.0 <4.0.0" + modular_core: ">=3.3.0 <4.0.0" meta: ">=1.3.0 <2.0.0" result_dart: ">=1.0.4 <2.0.0" flutter: diff --git a/modular_core/CHANGELOG.md b/modular_core/CHANGELOG.md index 3d078ab9..bf7af36f 100644 --- a/modular_core/CHANGELOG.md +++ b/modular_core/CHANGELOG.md @@ -1,4 +1,4 @@ -## 3.1.0+1 - 2023/08/24 +## 3.1.1 - 2023/08/24 * fix: Fix Import Modules Dependencies diff --git a/modular_core/lib/src/tracker.dart b/modular_core/lib/src/tracker.dart index c11be444..85090434 100644 --- a/modular_core/lib/src/tracker.dart +++ b/modular_core/lib/src/tracker.dart @@ -56,6 +56,7 @@ class _Tracker implements Tracker { final AutoInjector injector; final _disposeTags = >{}; + final _importedInjector = {}; Module? _nullableModule; @override @@ -251,11 +252,26 @@ class _Tracker implements Tracker { return newUrl.join('/'); } + AutoInjector _createExportedInjector(Module importedModule) { + final importTag = importedModule.runtimeType.toString(); + late AutoInjector exportedInject; + if (!_importedInjector.containsKey(importTag)) { + exportedInject = _createInjector(importedModule, '${importTag}_Imported'); + importedModule.exportedBinds(exportedInject); + } else { + exportedInject = _importedInjector[importTag]!; + } + + return exportedInject; + } + AutoInjector _createInjector(Module module, [String? tag]) { final newInjector = AutoInjector(tag: tag ?? module.runtimeType.toString()); for (final importedModule in module.imports) { - importedModule.exportedBinds(newInjector); + final exportedInject = _createExportedInjector(importedModule); + newInjector.addInjector(exportedInject); } + module.binds(newInjector); return newInjector; } diff --git a/modular_core/pubspec.yaml b/modular_core/pubspec.yaml index 36787cf2..b9eec494 100644 --- a/modular_core/pubspec.yaml +++ b/modular_core/pubspec.yaml @@ -1,6 +1,6 @@ name: modular_core description: Smart project structure with dependency injection and route management -version: 3.1.0+1 +version: 3.3.0 homepage: https://github.com/Flutterando/modular environment: