diff --git a/flutter_modular/.gitignore b/flutter_modular/.gitignore index 0fa6b675..5ab49131 100644 --- a/flutter_modular/.gitignore +++ b/flutter_modular/.gitignore @@ -44,3 +44,7 @@ app.*.map.json /android/app/debug /android/app/profile /android/app/release + + +# coverage +coverage/ \ No newline at end of file diff --git a/flutter_modular/CHANGELOG.md b/flutter_modular/CHANGELOG.md index fe3a2f86..71532679 100644 --- a/flutter_modular/CHANGELOG.md +++ b/flutter_modular/CHANGELOG.md @@ -1,4 +1,9 @@ -## [4.0.0+11] - 2021-09-16 +## [4.0.1] - 2021-09-22 +* Fixed pushNamed. +* Fixed bug that allowed access to parameters and arguments in other modules. +* Fixed transitions bug. + +## [4.0.0+12] - 2021-09-16 * New documentation is here! [https://modular.flutterando.com.br](https://modular.flutterando.com.br). * Modular design now uses Layered Architecture (Clean Architecture) with 100% code coverage. diff --git a/flutter_modular/lib/src/presenter/navigation/modular_router_delegate.dart b/flutter_modular/lib/src/presenter/navigation/modular_router_delegate.dart index ffc56720..55842c51 100644 --- a/flutter_modular/lib/src/presenter/navigation/modular_router_delegate.dart +++ b/flutter_modular/lib/src/presenter/navigation/modular_router_delegate.dart @@ -85,10 +85,6 @@ class ModularRouterDelegate extends RouterDelegate for (var disposableRoute in disposableRoutes) { reportPop.call(disposableRoute); } - - final arguments = - parser.getArguments().getOrElse((l) => ModularArguments.empty()); - parser.setArguments(arguments.copyWith(params: {}, data: null)); } var _lastClick = DateTime.now(); @@ -116,7 +112,11 @@ class ModularRouterDelegate extends RouterDelegate final parallel = page.route; parallel.popCallback?.call(result); currentConfiguration?.routes.remove(parallel); - reportPop.call(parallel); + if (currentConfiguration?.routes.indexWhere( + (element) => element.uri.toString() == parallel.uri.toString()) == + -1) { + reportPop.call(parallel); + } final arguments = parser.getArguments().getOrElse((l) => ModularArguments.empty()); parser.setArguments(arguments.copyWith(uri: currentConfiguration!.uri)); diff --git a/flutter_modular/pubspec.yaml b/flutter_modular/pubspec.yaml index f2113ae0..e974e411 100644 --- a/flutter_modular/pubspec.yaml +++ b/flutter_modular/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_modular description: Smart project structure with dependency injection and route management -version: 4.0.0+11 +version: 4.0.1 homepage: https://github.com/Flutterando/modular environment: @@ -9,7 +9,7 @@ environment: dependencies: flutter_modular_annotations: ^0.0.2 triple: ">=1.3.0+2 <2.0.0" - modular_core: ">=1.0.3 <=2.0.0" + modular_core: ">=1.0.4 <=2.0.0" meta: ">=1.3.0 <2.0.0" flutter: sdk: flutter diff --git a/modular_core/CHANGELOG.md b/modular_core/CHANGELOG.md index e6043ec4..8b9a82fd 100644 --- a/modular_core/CHANGELOG.md +++ b/modular_core/CHANGELOG.md @@ -1,5 +1,5 @@ -## 1.0.0+1 - 2021/09/21 -* Fix ordenation routes +## 1.0.4 - 2021/09/22 +* Rebuild modularArguments after get route ## 1.0.0+1 - 2021/09/05 * Stable version diff --git a/modular_core/lib/src/route/tracker.dart b/modular_core/lib/src/route/tracker.dart index 31dd4fd2..d633d6de 100644 --- a/modular_core/lib/src/route/tracker.dart +++ b/modular_core/lib/src/route/tracker.dart @@ -24,8 +24,7 @@ class TrackerImpl implements Tracker { String get currentPath => arguments.uri.toString(); - FutureOr findRoute(String path, - {dynamic data, String schema = ''}) async { + FutureOr findRoute(String path, {dynamic data, String schema = ''}) async { var uri = _resolverPath(path); final modularKey = ModularKey(schema: schema, name: uri.path); @@ -41,13 +40,11 @@ class TrackerImpl implements Tracker { break; } } - if (uriCandidate.pathSegments.length != uri.pathSegments.length && - !uriCandidate.path.contains('**')) { + if (uriCandidate.pathSegments.length != uri.pathSegments.length && !uriCandidate.path.contains('**')) { continue; } - if (!(uriCandidate.path.contains(':') || - uriCandidate.path.contains('**'))) { + if (!(uriCandidate.path.contains(':') || uriCandidate.path.contains('**'))) { continue; } @@ -75,7 +72,7 @@ class TrackerImpl implements Tracker { if (route == null) return null; - _arguments = arguments.copyWith(data: data, uri: uri, params: params); + _arguments = ModularArguments(uri: uri, data: data, params: params); return route; } @@ -139,6 +136,5 @@ class TrackerImpl implements Tracker { } class TrackerNotInitiated extends ModularError { - const TrackerNotInitiated(String message, [StackTrace? stackTrace]) - : super(message, stackTrace); + const TrackerNotInitiated(String message, [StackTrace? stackTrace]) : super(message, stackTrace); } diff --git a/modular_core/pubspec.yaml b/modular_core/pubspec.yaml index 94ff01dd..9307d645 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: 1.0.3 +version: 1.0.4 homepage: https://github.com/Flutterando/modular environment: diff --git a/modular_core/test/src/route/tracker_test.dart b/modular_core/test/src/route/tracker_test.dart index 73ccd610..ac563c3b 100644 --- a/modular_core/test/src/route/tracker_test.dart +++ b/modular_core/test/src/route/tracker_test.dart @@ -35,6 +35,8 @@ void main() { route = await ModularTracker.findRoute('/product/test') as CustomRoute?; expect(route?.uri.path, '/product/test'); + expect(ModularTracker.currentPath, '/product/test'); + expect(ModularTracker.arguments.params['id'], isNull); }); test('find route with queries', () async { @@ -53,8 +55,7 @@ void main() { }); test('find child route in other module', () async { - var route = - await ModularTracker.findRoute('/other/details') as CustomRoute?; + var route = await ModularTracker.findRoute('/other/details') as CustomRoute?; expect(route?.uri.path, '/other/details'); expect(route?.parent, '/other/'); expect(route?.data, 'otherWithDetails'); @@ -64,8 +65,7 @@ void main() { }); test('find child route in deep module', () async { - var route = - await ModularTracker.findRoute('/other/internal/') as CustomRoute?; + var route = await ModularTracker.findRoute('/other/internal/') as CustomRoute?; expect(route, isNotNull); ModularTracker.reportPushRoute(route!); expect(ModularTracker.injector.isModuleAlive(), true); @@ -75,8 +75,7 @@ void main() { ModularTracker.reportPopRoute(route); expect(ModularTracker.injector.isModuleAlive(), false); - route = - await ModularTracker.findRoute('/other/internal/deep') as CustomRoute?; + route = await ModularTracker.findRoute('/other/internal/deep') as CustomRoute?; expect(route, isNotNull); ModularTracker.reportPushRoute(route!); expect(ModularTracker.injector.isModuleAlive(), true); @@ -92,15 +91,13 @@ void main() { test('find route with schema', () async { expect(await ModularTracker.findRoute('/schema'), isNull); - final route = await ModularTracker.findRoute('/schema', schema: 'tag') - as CustomRoute?; + final route = await ModularTracker.findRoute('/schema', schema: 'tag') as CustomRoute?; expect(route?.uri.path, '/schema'); expect(route?.data, 'withSchema'); }); test('find route with wildcard', () async { - final route = - await ModularTracker.findRoute('/wildcard/test/2') as CustomRoute?; + final route = await ModularTracker.findRoute('/wildcard/test/2') as CustomRoute?; expect(route?.uri.path, '/wildcard/test/2'); expect(route?.data, 'wildcard'); }); diff --git a/modular_test/lib/modular_test.dart b/modular_test/lib/modular_test.dart index 586a7d8b..5643e6e4 100644 --- a/modular_test/lib/modular_test.dart +++ b/modular_test/lib/modular_test.dart @@ -2,8 +2,6 @@ library modular_test; import 'package:modular_core/modular_core.dart'; -void main() {} - void initModule(BindContext module, {List replaceBinds = const []}) { // ignore: invalid_use_of_visible_for_testing_member final bindModules = module.getProcessBinds(); diff --git a/modular_test/test/modular_test_test.dart b/modular_test/test/modular_test_test.dart index bdc29d37..b2a73074 100644 --- a/modular_test/test/modular_test_test.dart +++ b/modular_test/test/modular_test_test.dart @@ -28,8 +28,6 @@ class MyModule extends RouteContextImpl { void main() { final repo = RepoImpl2(); - modular_test.main(); - modular_test.initModules( [MyModule()], replaceBinds: [