From b97c3543ae9d6ce6c26027b87606d6b7b553bb4f Mon Sep 17 00:00:00 2001 From: Jacob Moura Date: Wed, 11 May 2022 19:49:00 -0300 Subject: [PATCH 1/8] fix: prepare to release --- flutter_modular/CHANGELOG.md | 1 + .../example/linux/flutter/generated_plugins.cmake | 8 ++++++++ .../example/windows/flutter/generated_plugins.cmake | 8 ++++++++ flutter_modular/pubspec.yaml | 4 ++-- modular_core/CHANGELOG.md | 2 +- modular_core/pubspec.yaml | 4 ++-- modular_interfaces/CHANGELOG.md | 3 ++- modular_interfaces/lib/src/di/bind.dart | 1 + modular_interfaces/pubspec.yaml | 2 +- .../example/windows/flutter/generated_plugins.cmake | 8 ++++++++ .../example/linux/flutter/generated_plugins.cmake | 8 ++++++++ .../example/windows/flutter/generated_plugins.cmake | 8 ++++++++ 12 files changed, 50 insertions(+), 7 deletions(-) diff --git a/flutter_modular/CHANGELOG.md b/flutter_modular/CHANGELOG.md index 2bc0b834..93017a63 100644 --- a/flutter_modular/CHANGELOG.md +++ b/flutter_modular/CHANGELOG.md @@ -1,4 +1,5 @@ ## [5.0.0] - 2022-04-21 +- Support Flutter 3.0.0 - [BREAK CHANGE]: Removed `MaterialApp.modular()` and `Cupertino().modular()`. Use instead: ```dart diff --git a/flutter_modular/example/linux/flutter/generated_plugins.cmake b/flutter_modular/example/linux/flutter/generated_plugins.cmake index 51436ae8..2e1de87a 100644 --- a/flutter_modular/example/linux/flutter/generated_plugins.cmake +++ b/flutter_modular/example/linux/flutter/generated_plugins.cmake @@ -5,6 +5,9 @@ list(APPEND FLUTTER_PLUGIN_LIST ) +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -13,3 +16,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/flutter_modular/example/windows/flutter/generated_plugins.cmake b/flutter_modular/example/windows/flutter/generated_plugins.cmake index 4d10c251..b93c4c30 100644 --- a/flutter_modular/example/windows/flutter/generated_plugins.cmake +++ b/flutter_modular/example/windows/flutter/generated_plugins.cmake @@ -5,6 +5,9 @@ list(APPEND FLUTTER_PLUGIN_LIST ) +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -13,3 +16,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/flutter_modular/pubspec.yaml b/flutter_modular/pubspec.yaml index 6a45280f..9c960b76 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: 5.0.0-dev.15 +version: 5.0.0 homepage: https://github.com/Flutterando/modular environment: @@ -8,7 +8,7 @@ environment: dependencies: flutter_modular_annotations: ^0.0.2 - modular_core: 2.0.0-dev.10 + modular_core: ">=2.0.0 <3.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 bd05a549..58bc90ae 100644 --- a/modular_core/CHANGELOG.md +++ b/modular_core/CHANGELOG.md @@ -1,4 +1,4 @@ -## 2.0.0 - 2022/04/21 +## 2.0.0 - 2022/05/11 * Remove `setDisposeResolver`. * Apply `BindContract.onDispose` of `modular_interface`. * Injetor.getBind now returns `BindEntry`. diff --git a/modular_core/pubspec.yaml b/modular_core/pubspec.yaml index 9f910ea2..c84d6108 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: 2.0.0-dev.10 +version: 2.0.0 homepage: https://github.com/Flutterando/modular environment: @@ -9,7 +9,7 @@ environment: dependencies: characters: ">=1.1.0 <2.0.0" meta: ">=1.3.0 <2.0.0" - modular_interfaces: "2.0.0-dev.12" + modular_interfaces: ">=2.0.0 <3.0.0" dev_dependencies: lints: ^1.0.1 diff --git a/modular_interfaces/CHANGELOG.md b/modular_interfaces/CHANGELOG.md index 0f4a8858..3c897ff3 100644 --- a/modular_interfaces/CHANGELOG.md +++ b/modular_interfaces/CHANGELOG.md @@ -1,6 +1,7 @@ -## 1.0.0+1 - 2022/04/21 +## 2.0.0 - 2022/05/11 - Added `BindContract.onDispose`. +- Added `BindContract.selector`. ## 1.0.0+1 - 2021/09/05 diff --git a/modular_interfaces/lib/src/di/bind.dart b/modular_interfaces/lib/src/di/bind.dart index 124d7b84..051a0270 100644 --- a/modular_interfaces/lib/src/di/bind.dart +++ b/modular_interfaces/lib/src/di/bind.dart @@ -15,6 +15,7 @@ abstract class BindContract { final bool isScoped; ///export bind for others modules + ///This bind can only be accessed when imported by a module. final bool export; ///When 'true', the object is instantiated only the first time it is called. diff --git a/modular_interfaces/pubspec.yaml b/modular_interfaces/pubspec.yaml index 58f296bd..79ec34c0 100644 --- a/modular_interfaces/pubspec.yaml +++ b/modular_interfaces/pubspec.yaml @@ -1,6 +1,6 @@ name: modular_interfaces description: Smart project structure with dependency injection and route management -version: 2.0.0-dev.12 +version: 2.0.0 homepage: https://github.com/Flutterando/modular # homepage: https://www.example.com diff --git a/plugins/modular_bloc_bind/example/windows/flutter/generated_plugins.cmake b/plugins/modular_bloc_bind/example/windows/flutter/generated_plugins.cmake index 4d10c251..b93c4c30 100644 --- a/plugins/modular_bloc_bind/example/windows/flutter/generated_plugins.cmake +++ b/plugins/modular_bloc_bind/example/windows/flutter/generated_plugins.cmake @@ -5,6 +5,9 @@ list(APPEND FLUTTER_PLUGIN_LIST ) +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -13,3 +16,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/plugins/modular_triple_bind/example/linux/flutter/generated_plugins.cmake b/plugins/modular_triple_bind/example/linux/flutter/generated_plugins.cmake index 51436ae8..2e1de87a 100644 --- a/plugins/modular_triple_bind/example/linux/flutter/generated_plugins.cmake +++ b/plugins/modular_triple_bind/example/linux/flutter/generated_plugins.cmake @@ -5,6 +5,9 @@ list(APPEND FLUTTER_PLUGIN_LIST ) +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -13,3 +16,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/plugins/modular_triple_bind/example/windows/flutter/generated_plugins.cmake b/plugins/modular_triple_bind/example/windows/flutter/generated_plugins.cmake index 4d10c251..b93c4c30 100644 --- a/plugins/modular_triple_bind/example/windows/flutter/generated_plugins.cmake +++ b/plugins/modular_triple_bind/example/windows/flutter/generated_plugins.cmake @@ -5,6 +5,9 @@ list(APPEND FLUTTER_PLUGIN_LIST ) +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -13,3 +16,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) From ef9d403515f90ffea0b7a648861fe4187273368e Mon Sep 17 00:00:00 2001 From: Jacob Moura Date: Wed, 11 May 2022 19:51:29 -0300 Subject: [PATCH 2/8] format files --- .../navigation/modular_router_delegate.dart | 103 ++++++++++++++---- .../modular_router_delegate_test.dart | 48 +++++--- .../presenter/widgets/modular_state_test.dart | 3 +- 3 files changed, 116 insertions(+), 38 deletions(-) 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 8e63b1da..52767967 100644 --- a/flutter_modular/lib/src/presenter/navigation/modular_router_delegate.dart +++ b/flutter_modular/lib/src/presenter/navigation/modular_router_delegate.dart @@ -24,7 +24,10 @@ class ModularRouterDelegate extends RouterDelegate final ReportPop reportPop; List observers = []; - ModularRouterDelegate({required this.parser, required this.navigatorKey, required this.reportPop}); + ModularRouterDelegate( + {required this.parser, + required this.navigatorKey, + required this.reportPop}); @override ModularBook? currentConfiguration; @@ -65,8 +68,11 @@ class ModularRouterDelegate extends RouterDelegate Future setNewRoutePath(ModularBook configuration) async { final disposableRoutes = []; - for (var route in currentConfiguration?.routes ?? >[]) { - if (configuration.routes.indexWhere((element) => element.uri.path == route.uri.path) == -1) { + for (var route + in currentConfiguration?.routes ?? >[]) { + if (configuration.routes + .indexWhere((element) => element.uri.path == route.uri.path) == + -1) { disposableRoutes.add(route); } } @@ -112,10 +118,13 @@ class ModularRouterDelegate extends RouterDelegate final parallel = page.route; parallel.popCallback?.call(result); currentConfiguration?.routes.remove(parallel); - if (currentConfiguration?.routes.indexWhere((element) => element.uri.toString() == parallel.uri.toString()) == -1) { + if (currentConfiguration?.routes.indexWhere( + (element) => element.uri.toString() == parallel.uri.toString()) == + -1) { reportPop.call(parallel); } - final arguments = parser.getArguments().getOrElse((l) => ModularArguments.empty()); + final arguments = + parser.getArguments().getOrElse((l) => ModularArguments.empty()); parser.setArguments(arguments.copyWith(uri: currentConfiguration!.uri)); notifyListeners(); @@ -123,17 +132,27 @@ class ModularRouterDelegate extends RouterDelegate } @override - Future pushNamed(String routeName, {Object? arguments, bool forRoot = false}) async { + Future pushNamed(String routeName, + {Object? arguments, bool forRoot = false}) async { final popComplete = Completer(); - var book = await parser.selectBook(routeName, arguments: arguments, popCallback: popComplete.complete); + var book = await parser.selectBook(routeName, + arguments: arguments, popCallback: popComplete.complete); if (forRoot) { - book = currentConfiguration!.copyWith(routes: [...currentConfiguration!.routes, book.routes.last.copyWith(schema: '')]); + book = currentConfiguration!.copyWith(routes: [ + ...currentConfiguration!.routes, + book.routes.last.copyWith(schema: '') + ]); await setNewRoutePath(book); } else { final list = [...currentConfiguration!.routes]; for (var route in book.routes.reversed) { - if (list.firstWhere((element) => element.uri.toString() == route.uri.toString(), orElse: () => ParallelRoute.empty()).name == '') { + if (list + .firstWhere( + (element) => element.uri.toString() == route.uri.toString(), + orElse: () => ParallelRoute.empty()) + .name == + '') { list.add(route); } } @@ -149,13 +168,19 @@ class ModularRouterDelegate extends RouterDelegate } @override - Future pushReplacementNamed(String routeName, {TO? result, Object? arguments, bool forRoot = false}) async { + Future pushReplacementNamed( + String routeName, + {TO? result, + Object? arguments, + bool forRoot = false}) async { final popComplete = Completer(); - var book = await parser.selectBook(routeName, arguments: arguments, popCallback: popComplete.complete); + var book = await parser.selectBook(routeName, + arguments: arguments, popCallback: popComplete.complete); final currentRoutes = [...currentConfiguration!.routes]; if (forRoot) { //;currentRoutes.removeWhere((element) => element.schema != ''); - final indexLast = currentRoutes.lastIndexWhere((element) => element.schema == ''); + final indexLast = + currentRoutes.lastIndexWhere((element) => element.schema == ''); currentRoutes[indexLast] = book.routes.first.copyWith(schema: ''); book = currentConfiguration!.copyWith(routes: [...currentRoutes]); await setNewRoutePath(book); @@ -163,7 +188,12 @@ class ModularRouterDelegate extends RouterDelegate final list = currentRoutes..removeLast(); for (var route in book.routes.reversed) { - if (list.firstWhere((element) => element.uri.toString() == route.uri.toString(), orElse: () => ParallelRoute.empty()).name == '') { + if (list + .firstWhere( + (element) => element.uri.toString() == route.uri.toString(), + orElse: () => ParallelRoute.empty()) + .name == + '') { list.add(route); } } @@ -174,7 +204,11 @@ class ModularRouterDelegate extends RouterDelegate } @override - Future popAndPushNamed(String routeName, {TO? result, Object? arguments, bool forRoot = false}) { + Future popAndPushNamed( + String routeName, + {TO? result, + Object? arguments, + bool forRoot = false}) { pop(result); return pushNamed(routeName, arguments: arguments); } @@ -183,15 +217,20 @@ class ModularRouterDelegate extends RouterDelegate bool canPop() => navigatorKey.currentState?.canPop() ?? false; @override - Future maybePop([T? result]) => navigatorKey.currentState?.maybePop(result) ?? Future.value(false); + Future maybePop([T? result]) => + navigatorKey.currentState?.maybePop(result) ?? Future.value(false); @override - void pop([T? result]) => navigatorKey.currentState?.pop(result); + void pop([T? result]) => + navigatorKey.currentState?.pop(result); @override void popUntil(bool Function(Route) predicate) { var isFoundedPages = currentConfiguration?.routes.where((route) { - return predicate(CustomModalRoute(ModularPage(route: route, args: ModularArguments.empty(), flags: ModularFlags()))); + return predicate(CustomModalRoute(ModularPage( + route: route, + args: ModularArguments.empty(), + flags: ModularFlags()))); }); isFoundedPages ??= []; @@ -203,21 +242,36 @@ class ModularRouterDelegate extends RouterDelegate } @override - Future pushNamedAndRemoveUntil(String routeName, bool Function(Route) predicate, {Object? arguments, bool forRoot = false}) async { + Future pushNamedAndRemoveUntil( + String routeName, bool Function(Route) predicate, + {Object? arguments, bool forRoot = false}) async { final popComplete = Completer(); - var book = await parser.selectBook(routeName, arguments: arguments, popCallback: popComplete.complete); + var book = await parser.selectBook(routeName, + arguments: arguments, popCallback: popComplete.complete); if (forRoot) { final list = currentConfiguration!.routes.where((route) { - return predicate(CustomModalRoute(ModularPage(route: route, args: ModularArguments.empty(), flags: ModularFlags()))); + return predicate(CustomModalRoute(ModularPage( + route: route, + args: ModularArguments.empty(), + flags: ModularFlags()))); }).toList(); - book = currentConfiguration!.copyWith(routes: [...list, book.routes.last.copyWith(schema: '')]); + book = currentConfiguration! + .copyWith(routes: [...list, book.routes.last.copyWith(schema: '')]); await setNewRoutePath(book); } else { final list = currentConfiguration!.routes.where((route) { - return predicate(CustomModalRoute(ModularPage(route: route, args: ModularArguments.empty(), flags: ModularFlags()))); + return predicate(CustomModalRoute(ModularPage( + route: route, + args: ModularArguments.empty(), + flags: ModularFlags()))); }).toList(); for (var route in book.routes.reversed) { - if (list.firstWhere((element) => element.uri.toString() == route.uri.toString(), orElse: () => ParallelRoute.empty()).name == '') { + if (list + .firstWhere( + (element) => element.uri.toString() == route.uri.toString(), + orElse: () => ParallelRoute.empty()) + .name == + '') { list.add(route); } } @@ -250,7 +304,8 @@ class CustomModalRoute extends ModalRoute { String? get barrierLabel => throw UnimplementedError(); @override - Widget buildPage(BuildContext context, Animation animation, Animation secondaryAnimation) { + Widget buildPage(BuildContext context, Animation animation, + Animation secondaryAnimation) { throw UnimplementedError(); } diff --git a/flutter_modular/test/src/presenter/navigation/modular_router_delegate_test.dart b/flutter_modular/test/src/presenter/navigation/modular_router_delegate_test.dart index 51662992..246f81e0 100644 --- a/flutter_modular/test/src/presenter/navigation/modular_router_delegate_test.dart +++ b/flutter_modular/test/src/presenter/navigation/modular_router_delegate_test.dart @@ -16,7 +16,8 @@ import '../modular_base_test.dart' hide GetArgumentsMock, SetArgumentsMock; import 'modular_page_test.dart'; import 'modular_route_information_parser_test.dart'; -class ModularRouteInformationParserMock extends Mock implements ModularRouteInformationParser {} +class ModularRouteInformationParserMock extends Mock + implements ModularRouteInformationParser {} class BuildContextMock extends Mock implements BuildContext {} @@ -91,7 +92,8 @@ void main() { test('navigate blink', () async { final route1 = ParallelRouteMock(); when(() => route1.uri).thenReturn(Uri.parse('/test2')); - when(() => parser.selectBook('/test2')).thenAnswer((_) async => ModularBook(routes: [route1])); + when(() => parser.selectBook('/test2')) + .thenAnswer((_) async => ModularBook(routes: [route1])); delegate.navigate('/test'); delegate.navigate('/test2'); @@ -106,7 +108,8 @@ void main() { test('navigate', () async { final route1 = ParallelRouteMock(); when(() => route1.uri).thenReturn(Uri.parse('/test')); - when(() => parser.selectBook('/test')).thenAnswer((_) async => ModularBook(routes: [route1])); + when(() => parser.selectBook('/test')) + .thenAnswer((_) async => ModularBook(routes: [route1])); final getArgsMock = GetArgumentsMock(); final setArgsMock = SetArgumentsMock(); @@ -131,7 +134,8 @@ void main() { final route = RouteMock(); final parallel = ParallelRouteMock(); when(() => parallel.uri).thenReturn(Uri.parse('/')); - final page = ModularPage(route: parallel, args: ModularArguments.empty(), flags: ModularFlags()); + final page = ModularPage( + route: parallel, args: ModularArguments.empty(), flags: ModularFlags()); when(() => route.didPop(null)).thenReturn(true); when(() => route.settings).thenReturn(page); when(() => route.isFirst).thenReturn(false); @@ -178,7 +182,9 @@ void main() { delegate.currentConfiguration = ModularBook(routes: [route1]); - when(() => parser.selectBook('/pushForce', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route2])); + when(() => parser.selectBook('/pushForce', + popCallback: any(named: 'popCallback'))) + .thenAnswer((_) async => ModularBook(routes: [route2])); // ignore: unawaited_futures delegate.pushNamed('/pushForce', forRoot: true); await Future.delayed(const Duration(milliseconds: 400)); @@ -213,7 +219,9 @@ void main() { delegate.currentConfiguration = ModularBook(routes: [route1]); - when(() => parser.selectBook('/pushForce', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route2])); + when(() => parser.selectBook('/pushForce', + popCallback: any(named: 'popCallback'))) + .thenAnswer((_) async => ModularBook(routes: [route2])); // ignore: unawaited_futures delegate.pushNamed('/pushForce'); await Future.delayed(const Duration(milliseconds: 400)); @@ -251,7 +259,9 @@ void main() { delegate.currentConfiguration = ModularBook(routes: [route1]); - when(() => parser.selectBook('/pushForce', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route2])); + when(() => parser.selectBook('/pushForce', + popCallback: any(named: 'popCallback'))) + .thenAnswer((_) async => ModularBook(routes: [route2])); // ignore: unawaited_futures delegate.pushReplacementNamed('/pushForce', forRoot: true); await Future.delayed(const Duration(milliseconds: 400)); @@ -294,7 +304,9 @@ void main() { delegate.currentConfiguration = ModularBook(routes: [route1, route2]); - when(() => parser.selectBook('/pushForce', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route3])); + when(() => parser.selectBook('/pushForce', + popCallback: any(named: 'popCallback'))) + .thenAnswer((_) async => ModularBook(routes: [route3])); // ignore: unawaited_futures delegate.pushReplacementNamed('/pushForce'); await Future.delayed(const Duration(milliseconds: 400)); @@ -328,7 +340,9 @@ void main() { delegate.currentConfiguration = ModularBook(routes: [route1]); - when(() => parser.selectBook('/pushForce', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route2])); + when(() => parser.selectBook('/pushForce', + popCallback: any(named: 'popCallback'))) + .thenAnswer((_) async => ModularBook(routes: [route2])); // ignore: unawaited_futures delegate.popAndPushNamed('/pushForce'); await Future.delayed(const Duration(milliseconds: 400)); @@ -344,7 +358,8 @@ void main() { }); test('push ', () async { final route = MaterialPageRoute(builder: (_) => Container()); - when(() => navigatorState.push(route)).thenAnswer((_) => Future.value(true)); + when(() => navigatorState.push(route)) + .thenAnswer((_) => Future.value(true)); await delegate.push(route); verify(() => navigatorState.push(route)); }); @@ -405,7 +420,9 @@ void main() { delegate.currentConfiguration = ModularBook(routes: [route1]); - when(() => parser.selectBook('/pushForce', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route2])); + when(() => parser.selectBook('/pushForce', + popCallback: any(named: 'popCallback'))) + .thenAnswer((_) async => ModularBook(routes: [route2])); // ignore: unawaited_futures delegate.pushNamedAndRemoveUntil('/pushForce', (_) => false); await Future.delayed(const Duration(milliseconds: 400)); @@ -442,7 +459,9 @@ void main() { delegate.currentConfiguration = ModularBook(routes: [route1]); - when(() => parser.selectBook('/pushForce', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route2])); + when(() => parser.selectBook('/pushForce', + popCallback: any(named: 'popCallback'))) + .thenAnswer((_) async => ModularBook(routes: [route2])); // ignore: unawaited_futures delegate.pushNamedAndRemoveUntil('/pushForce', (_) => false, forRoot: true); await Future.delayed(const Duration(milliseconds: 400)); @@ -459,6 +478,9 @@ void main() { expect(() => route.opaque, throwsA(isA())); expect(() => route.transitionDuration, throwsA(isA())); expect(() => route.barrierLabel, throwsA(isA())); - expect(() => route.buildPage(BuildContextMock(), AnimationMock(), AnimationMock()), throwsA(isA())); + expect( + () => route.buildPage( + BuildContextMock(), AnimationMock(), AnimationMock()), + throwsA(isA())); }); } diff --git a/flutter_modular/test/src/presenter/widgets/modular_state_test.dart b/flutter_modular/test/src/presenter/widgets/modular_state_test.dart index 01baffdd..1eeb18ab 100644 --- a/flutter_modular/test/src/presenter/widgets/modular_state_test.dart +++ b/flutter_modular/test/src/presenter/widgets/modular_state_test.dart @@ -4,7 +4,8 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('ModularState', (tester) async { - final modularApp = ModularApp(module: CustomModule(), child: const AppWidget()); + final modularApp = + ModularApp(module: CustomModule(), child: const AppWidget()); await tester.pumpWidget(modularApp); await tester.pump(); From 6dd09b5f34d9399813a3a40d9dde6f4483f0c791 Mon Sep 17 00:00:00 2001 From: Jacob Moura Date: Wed, 11 May 2022 20:01:23 -0300 Subject: [PATCH 3/8] fix tests --- modular_test/lib/modular_test.dart | 1 + modular_test/pubspec.yaml | 4 ++-- modular_test/test/modular_test_test.dart | 27 +++++++++++++++++++----- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/modular_test/lib/modular_test.dart b/modular_test/lib/modular_test.dart index cc83b43a..0305257e 100644 --- a/modular_test/lib/modular_test.dart +++ b/modular_test/lib/modular_test.dart @@ -15,6 +15,7 @@ void initModule(BindContext module, {List replaceBinds = const []} bindModules[i] = dep; } } + module.changeBinds(bindModules); modularTracker.injector.addBindContext(module); } diff --git a/modular_test/pubspec.yaml b/modular_test/pubspec.yaml index 0b2ac471..3b7f4b15 100644 --- a/modular_test/pubspec.yaml +++ b/modular_test/pubspec.yaml @@ -1,13 +1,13 @@ name: modular_test description: Smart project structure with dependency injection and route management -version: 2.0.0-dev.1 +version: 2.0.0 homepage: https://github.com/Flutterando/modular environment: sdk: ">=2.12.0 <3.0.0" dependencies: - modular_core: ">=1.2.2 <3.0.0" + modular_core: ">=2.0.0 <3.0.0" dev_dependencies: lints: ^1.0.1 diff --git a/modular_test/test/modular_test_test.dart b/modular_test/test/modular_test_test.dart index e100e08d..319b58d4 100644 --- a/modular_test/test/modular_test_test.dart +++ b/modular_test/test/modular_test_test.dart @@ -1,8 +1,7 @@ +import 'package:modular_core/modular_core.dart'; import 'package:modular_test/modular_test.dart' as modular_test; import 'package:test/test.dart'; -import 'package:modular_core/modular_core.dart'; - abstract class IRepo { String get name; } @@ -38,17 +37,17 @@ void main() { ); test('init Module', () { - final text = modularTracker.injector.get(); + final text = modularTracker.injector.get().value; expect(text, 'teste'); }); test('replace binds', () { - final boolean = modularTracker.injector.get(); + final boolean = modularTracker.injector.get().value; expect(boolean, false); }); test('replace binds with interface', () { - final result = modularTracker.injector.get(); + final result = modularTracker.injector.get().value; expect(result, isA()); expect(result.name, 'RepoImpl2'); }); @@ -56,4 +55,22 @@ void main() { class _Bind extends BindContract { _Bind(T Function(Injector i) factoryFunction) : super(factoryFunction); + + @override + BindContract cast() { + return _Bind(factoryFunction as E Function(Injector i)); + } + + @override + BindContract copyWith( + {T Function(Injector i)? factoryFunction, + bool? isSingleton, + bool? isLazy, + bool? export, + bool? isScoped, + bool? alwaysSerialized, + void Function(T value)? onDispose, + Function(T value)? selector}) { + return this; + } } From a566a1581c3c875bdbce873adf6a657e6e7ea018 Mon Sep 17 00:00:00 2001 From: Jacob Moura Date: Wed, 11 May 2022 20:25:19 -0300 Subject: [PATCH 4/8] fix test --- shelf_modular/pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shelf_modular/pubspec.yaml b/shelf_modular/pubspec.yaml index 9d9e59f4..5d163be2 100644 --- a/shelf_modular/pubspec.yaml +++ b/shelf_modular/pubspec.yaml @@ -1,6 +1,6 @@ name: shelf_modular description: Smart project structure with dependency injection and route management -version: 1.0.2 +version: 1.0.3 homepage: https://github.com/Flutterando/modular environment: @@ -10,7 +10,7 @@ dependencies: args: ^2.2.0 shelf: ^1.1.0 meta: ">=1.3.0 <2.0.0" - modular_core: ">=1.2.2 <=2.0.0" + modular_core: ">=1.2.2 <2.0.0" mime: ^1.0.0 http_parser: ^4.0.0 web_socket_channel: ^2.1.0 From e57e5e7e6192bc988b9b26a63956537e53f00c35 Mon Sep 17 00:00:00 2001 From: Jacob Moura Date: Wed, 11 May 2022 20:56:04 -0300 Subject: [PATCH 5/8] fix tests --- .../windows/flutter/generated_plugins.cmake | 8 ---- .../modular_router_delegate_test.dart | 37 +++++++++++-------- modular.code-workspace | 2 +- .../windows/flutter/generated_plugins.cmake | 8 ---- .../windows/flutter/generated_plugins.cmake | 8 ---- 5 files changed, 23 insertions(+), 40 deletions(-) diff --git a/flutter_modular/example/windows/flutter/generated_plugins.cmake b/flutter_modular/example/windows/flutter/generated_plugins.cmake index b93c4c30..4d10c251 100644 --- a/flutter_modular/example/windows/flutter/generated_plugins.cmake +++ b/flutter_modular/example/windows/flutter/generated_plugins.cmake @@ -5,9 +5,6 @@ list(APPEND FLUTTER_PLUGIN_LIST ) -list(APPEND FLUTTER_FFI_PLUGIN_LIST -) - set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -16,8 +13,3 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) - -foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) -endforeach(ffi_plugin) diff --git a/flutter_modular/test/src/presenter/navigation/modular_router_delegate_test.dart b/flutter_modular/test/src/presenter/navigation/modular_router_delegate_test.dart index 246f81e0..9cbf9633 100644 --- a/flutter_modular/test/src/presenter/navigation/modular_router_delegate_test.dart +++ b/flutter_modular/test/src/presenter/navigation/modular_router_delegate_test.dart @@ -395,6 +395,18 @@ void main() { test('pushNamedAndRemoveUntil ', () async { final route1 = ParallelRouteMock(); final route2 = ParallelRouteMock(); + final route3 = ParallelRouteMock(); + + final arguments = ModularArguments.empty(); + + final getArgsMock = GetArgumentsMock(); + final setArgsMock = SetArgumentsMock(); + + when(() => getArgsMock.call()).thenReturn(right(arguments)); + when(() => setArgsMock.call(any())).thenReturn(right(unit)); + + when(() => parser.getArguments).thenReturn(getArgsMock); + when(() => parser.setArguments).thenReturn(setArgsMock); when(() => reportPopMock.call(any())).thenReturn(right(unit)); @@ -406,28 +418,23 @@ void main() { when(() => route2.copyWith(schema: '')).thenReturn(route2); when(() => route2.schema).thenReturn(''); - when(() => navigatorState.popUntil(any())).thenReturn(null); - - final getArgsMock = GetArgumentsMock(); - final setArgsMock = SetArgumentsMock(); - when(() => parser.getArguments).thenReturn(getArgsMock); - when(() => parser.setArguments).thenReturn(setArgsMock); - - final arguments = ModularArguments.empty(); + when(() => route3.uri).thenReturn(Uri.parse('/pushForce2')); + when(() => route3.copyWith(schema: '')).thenReturn(route3); + when(() => route3.schema).thenReturn(''); - when(() => getArgsMock.call()).thenReturn(right(arguments)); - when(() => setArgsMock.call(any())).thenReturn(right(unit)); + when(() => navigatorState.popUntil(any())).thenReturn(null); - delegate.currentConfiguration = ModularBook(routes: [route1]); + delegate.currentConfiguration = + ModularBook(routes: [route1, route2, route3]); - when(() => parser.selectBook('/pushForce', + when(() => parser.selectBook('/pushForce2', popCallback: any(named: 'popCallback'))) - .thenAnswer((_) async => ModularBook(routes: [route2])); + .thenAnswer((_) async => ModularBook(routes: [route3])); // ignore: unawaited_futures - delegate.pushNamedAndRemoveUntil('/pushForce', (_) => false); + delegate.pushNamedAndRemoveUntil('/pushForce2', (_) => false); await Future.delayed(const Duration(milliseconds: 400)); - expect(delegate.currentConfiguration?.uri.toString(), '/pushForce'); + expect(delegate.currentConfiguration?.uri.toString(), '/pushForce2'); expect(delegate.currentConfiguration?.routes.length, 1); }); diff --git a/modular.code-workspace b/modular.code-workspace index da773f5a..8c6fb348 100644 --- a/modular.code-workspace +++ b/modular.code-workspace @@ -35,7 +35,7 @@ } ], "settings": { - "dart.flutterSdkPath": "D:\\fvm\\sdks\\versions\\stable", + "dart.flutterSdkPath": "D:\\fvm\\sdks\\versions\\2.10.5", "lcov.branchCoverage": "off", "lcov.path": "coverage/lcov.info" } diff --git a/plugins/modular_bloc_bind/example/windows/flutter/generated_plugins.cmake b/plugins/modular_bloc_bind/example/windows/flutter/generated_plugins.cmake index b93c4c30..4d10c251 100644 --- a/plugins/modular_bloc_bind/example/windows/flutter/generated_plugins.cmake +++ b/plugins/modular_bloc_bind/example/windows/flutter/generated_plugins.cmake @@ -5,9 +5,6 @@ list(APPEND FLUTTER_PLUGIN_LIST ) -list(APPEND FLUTTER_FFI_PLUGIN_LIST -) - set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -16,8 +13,3 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) - -foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) -endforeach(ffi_plugin) diff --git a/plugins/modular_triple_bind/example/windows/flutter/generated_plugins.cmake b/plugins/modular_triple_bind/example/windows/flutter/generated_plugins.cmake index b93c4c30..4d10c251 100644 --- a/plugins/modular_triple_bind/example/windows/flutter/generated_plugins.cmake +++ b/plugins/modular_triple_bind/example/windows/flutter/generated_plugins.cmake @@ -5,9 +5,6 @@ list(APPEND FLUTTER_PLUGIN_LIST ) -list(APPEND FLUTTER_FFI_PLUGIN_LIST -) - set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -16,8 +13,3 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) - -foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) -endforeach(ffi_plugin) From 08d33e124b550f83bb7a2ec8352dceafea27f68b Mon Sep 17 00:00:00 2001 From: Jacob Moura Date: Wed, 11 May 2022 21:04:19 -0300 Subject: [PATCH 6/8] fix test --- .../modular_router_delegate_test.dart | 55 ++++++------------- 1 file changed, 16 insertions(+), 39 deletions(-) diff --git a/flutter_modular/test/src/presenter/navigation/modular_router_delegate_test.dart b/flutter_modular/test/src/presenter/navigation/modular_router_delegate_test.dart index 9cbf9633..8247307f 100644 --- a/flutter_modular/test/src/presenter/navigation/modular_router_delegate_test.dart +++ b/flutter_modular/test/src/presenter/navigation/modular_router_delegate_test.dart @@ -16,8 +16,7 @@ import '../modular_base_test.dart' hide GetArgumentsMock, SetArgumentsMock; import 'modular_page_test.dart'; import 'modular_route_information_parser_test.dart'; -class ModularRouteInformationParserMock extends Mock - implements ModularRouteInformationParser {} +class ModularRouteInformationParserMock extends Mock implements ModularRouteInformationParser {} class BuildContextMock extends Mock implements BuildContext {} @@ -92,8 +91,7 @@ void main() { test('navigate blink', () async { final route1 = ParallelRouteMock(); when(() => route1.uri).thenReturn(Uri.parse('/test2')); - when(() => parser.selectBook('/test2')) - .thenAnswer((_) async => ModularBook(routes: [route1])); + when(() => parser.selectBook('/test2')).thenAnswer((_) async => ModularBook(routes: [route1])); delegate.navigate('/test'); delegate.navigate('/test2'); @@ -108,8 +106,7 @@ void main() { test('navigate', () async { final route1 = ParallelRouteMock(); when(() => route1.uri).thenReturn(Uri.parse('/test')); - when(() => parser.selectBook('/test')) - .thenAnswer((_) async => ModularBook(routes: [route1])); + when(() => parser.selectBook('/test')).thenAnswer((_) async => ModularBook(routes: [route1])); final getArgsMock = GetArgumentsMock(); final setArgsMock = SetArgumentsMock(); @@ -134,8 +131,7 @@ void main() { final route = RouteMock(); final parallel = ParallelRouteMock(); when(() => parallel.uri).thenReturn(Uri.parse('/')); - final page = ModularPage( - route: parallel, args: ModularArguments.empty(), flags: ModularFlags()); + final page = ModularPage(route: parallel, args: ModularArguments.empty(), flags: ModularFlags()); when(() => route.didPop(null)).thenReturn(true); when(() => route.settings).thenReturn(page); when(() => route.isFirst).thenReturn(false); @@ -182,9 +178,7 @@ void main() { delegate.currentConfiguration = ModularBook(routes: [route1]); - when(() => parser.selectBook('/pushForce', - popCallback: any(named: 'popCallback'))) - .thenAnswer((_) async => ModularBook(routes: [route2])); + when(() => parser.selectBook('/pushForce', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route2])); // ignore: unawaited_futures delegate.pushNamed('/pushForce', forRoot: true); await Future.delayed(const Duration(milliseconds: 400)); @@ -219,9 +213,7 @@ void main() { delegate.currentConfiguration = ModularBook(routes: [route1]); - when(() => parser.selectBook('/pushForce', - popCallback: any(named: 'popCallback'))) - .thenAnswer((_) async => ModularBook(routes: [route2])); + when(() => parser.selectBook('/pushForce', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route2])); // ignore: unawaited_futures delegate.pushNamed('/pushForce'); await Future.delayed(const Duration(milliseconds: 400)); @@ -259,9 +251,7 @@ void main() { delegate.currentConfiguration = ModularBook(routes: [route1]); - when(() => parser.selectBook('/pushForce', - popCallback: any(named: 'popCallback'))) - .thenAnswer((_) async => ModularBook(routes: [route2])); + when(() => parser.selectBook('/pushForce', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route2])); // ignore: unawaited_futures delegate.pushReplacementNamed('/pushForce', forRoot: true); await Future.delayed(const Duration(milliseconds: 400)); @@ -304,9 +294,7 @@ void main() { delegate.currentConfiguration = ModularBook(routes: [route1, route2]); - when(() => parser.selectBook('/pushForce', - popCallback: any(named: 'popCallback'))) - .thenAnswer((_) async => ModularBook(routes: [route3])); + when(() => parser.selectBook('/pushForce', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route3])); // ignore: unawaited_futures delegate.pushReplacementNamed('/pushForce'); await Future.delayed(const Duration(milliseconds: 400)); @@ -340,9 +328,7 @@ void main() { delegate.currentConfiguration = ModularBook(routes: [route1]); - when(() => parser.selectBook('/pushForce', - popCallback: any(named: 'popCallback'))) - .thenAnswer((_) async => ModularBook(routes: [route2])); + when(() => parser.selectBook('/pushForce', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route2])); // ignore: unawaited_futures delegate.popAndPushNamed('/pushForce'); await Future.delayed(const Duration(milliseconds: 400)); @@ -358,8 +344,7 @@ void main() { }); test('push ', () async { final route = MaterialPageRoute(builder: (_) => Container()); - when(() => navigatorState.push(route)) - .thenAnswer((_) => Future.value(true)); + when(() => navigatorState.push(route)).thenAnswer((_) => Future.value(true)); await delegate.push(route); verify(() => navigatorState.push(route)); }); @@ -424,18 +409,15 @@ void main() { when(() => navigatorState.popUntil(any())).thenReturn(null); - delegate.currentConfiguration = - ModularBook(routes: [route1, route2, route3]); + delegate.currentConfiguration = ModularBook(routes: [route1, route2, route3]); - when(() => parser.selectBook('/pushForce2', - popCallback: any(named: 'popCallback'))) - .thenAnswer((_) async => ModularBook(routes: [route3])); + when(() => parser.selectBook('/pushForce2', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route3])); // ignore: unawaited_futures - delegate.pushNamedAndRemoveUntil('/pushForce2', (_) => false); + delegate.pushNamedAndRemoveUntil('/pushForce2', ModalRoute.withName('/')); await Future.delayed(const Duration(milliseconds: 400)); expect(delegate.currentConfiguration?.uri.toString(), '/pushForce2'); - expect(delegate.currentConfiguration?.routes.length, 1); + expect(delegate.currentConfiguration?.routes.length, 2); }); test('pushNamedAndRemoveUntil forRoot', () async { @@ -466,9 +448,7 @@ void main() { delegate.currentConfiguration = ModularBook(routes: [route1]); - when(() => parser.selectBook('/pushForce', - popCallback: any(named: 'popCallback'))) - .thenAnswer((_) async => ModularBook(routes: [route2])); + when(() => parser.selectBook('/pushForce', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route2])); // ignore: unawaited_futures delegate.pushNamedAndRemoveUntil('/pushForce', (_) => false, forRoot: true); await Future.delayed(const Duration(milliseconds: 400)); @@ -485,9 +465,6 @@ void main() { expect(() => route.opaque, throwsA(isA())); expect(() => route.transitionDuration, throwsA(isA())); expect(() => route.barrierLabel, throwsA(isA())); - expect( - () => route.buildPage( - BuildContextMock(), AnimationMock(), AnimationMock()), - throwsA(isA())); + expect(() => route.buildPage(BuildContextMock(), AnimationMock(), AnimationMock()), throwsA(isA())); }); } From 119de1d90806e462940094bad420e00afa3fa607 Mon Sep 17 00:00:00 2001 From: Jacob Moura Date: Wed, 11 May 2022 21:06:21 -0300 Subject: [PATCH 7/8] fix format --- .../modular_router_delegate_test.dart | 51 ++++++++++++++----- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/flutter_modular/test/src/presenter/navigation/modular_router_delegate_test.dart b/flutter_modular/test/src/presenter/navigation/modular_router_delegate_test.dart index 8247307f..e5518442 100644 --- a/flutter_modular/test/src/presenter/navigation/modular_router_delegate_test.dart +++ b/flutter_modular/test/src/presenter/navigation/modular_router_delegate_test.dart @@ -16,7 +16,8 @@ import '../modular_base_test.dart' hide GetArgumentsMock, SetArgumentsMock; import 'modular_page_test.dart'; import 'modular_route_information_parser_test.dart'; -class ModularRouteInformationParserMock extends Mock implements ModularRouteInformationParser {} +class ModularRouteInformationParserMock extends Mock + implements ModularRouteInformationParser {} class BuildContextMock extends Mock implements BuildContext {} @@ -91,7 +92,8 @@ void main() { test('navigate blink', () async { final route1 = ParallelRouteMock(); when(() => route1.uri).thenReturn(Uri.parse('/test2')); - when(() => parser.selectBook('/test2')).thenAnswer((_) async => ModularBook(routes: [route1])); + when(() => parser.selectBook('/test2')) + .thenAnswer((_) async => ModularBook(routes: [route1])); delegate.navigate('/test'); delegate.navigate('/test2'); @@ -106,7 +108,8 @@ void main() { test('navigate', () async { final route1 = ParallelRouteMock(); when(() => route1.uri).thenReturn(Uri.parse('/test')); - when(() => parser.selectBook('/test')).thenAnswer((_) async => ModularBook(routes: [route1])); + when(() => parser.selectBook('/test')) + .thenAnswer((_) async => ModularBook(routes: [route1])); final getArgsMock = GetArgumentsMock(); final setArgsMock = SetArgumentsMock(); @@ -131,7 +134,8 @@ void main() { final route = RouteMock(); final parallel = ParallelRouteMock(); when(() => parallel.uri).thenReturn(Uri.parse('/')); - final page = ModularPage(route: parallel, args: ModularArguments.empty(), flags: ModularFlags()); + final page = ModularPage( + route: parallel, args: ModularArguments.empty(), flags: ModularFlags()); when(() => route.didPop(null)).thenReturn(true); when(() => route.settings).thenReturn(page); when(() => route.isFirst).thenReturn(false); @@ -178,7 +182,9 @@ void main() { delegate.currentConfiguration = ModularBook(routes: [route1]); - when(() => parser.selectBook('/pushForce', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route2])); + when(() => parser.selectBook('/pushForce', + popCallback: any(named: 'popCallback'))) + .thenAnswer((_) async => ModularBook(routes: [route2])); // ignore: unawaited_futures delegate.pushNamed('/pushForce', forRoot: true); await Future.delayed(const Duration(milliseconds: 400)); @@ -213,7 +219,9 @@ void main() { delegate.currentConfiguration = ModularBook(routes: [route1]); - when(() => parser.selectBook('/pushForce', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route2])); + when(() => parser.selectBook('/pushForce', + popCallback: any(named: 'popCallback'))) + .thenAnswer((_) async => ModularBook(routes: [route2])); // ignore: unawaited_futures delegate.pushNamed('/pushForce'); await Future.delayed(const Duration(milliseconds: 400)); @@ -251,7 +259,9 @@ void main() { delegate.currentConfiguration = ModularBook(routes: [route1]); - when(() => parser.selectBook('/pushForce', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route2])); + when(() => parser.selectBook('/pushForce', + popCallback: any(named: 'popCallback'))) + .thenAnswer((_) async => ModularBook(routes: [route2])); // ignore: unawaited_futures delegate.pushReplacementNamed('/pushForce', forRoot: true); await Future.delayed(const Duration(milliseconds: 400)); @@ -294,7 +304,9 @@ void main() { delegate.currentConfiguration = ModularBook(routes: [route1, route2]); - when(() => parser.selectBook('/pushForce', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route3])); + when(() => parser.selectBook('/pushForce', + popCallback: any(named: 'popCallback'))) + .thenAnswer((_) async => ModularBook(routes: [route3])); // ignore: unawaited_futures delegate.pushReplacementNamed('/pushForce'); await Future.delayed(const Duration(milliseconds: 400)); @@ -328,7 +340,9 @@ void main() { delegate.currentConfiguration = ModularBook(routes: [route1]); - when(() => parser.selectBook('/pushForce', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route2])); + when(() => parser.selectBook('/pushForce', + popCallback: any(named: 'popCallback'))) + .thenAnswer((_) async => ModularBook(routes: [route2])); // ignore: unawaited_futures delegate.popAndPushNamed('/pushForce'); await Future.delayed(const Duration(milliseconds: 400)); @@ -344,7 +358,8 @@ void main() { }); test('push ', () async { final route = MaterialPageRoute(builder: (_) => Container()); - when(() => navigatorState.push(route)).thenAnswer((_) => Future.value(true)); + when(() => navigatorState.push(route)) + .thenAnswer((_) => Future.value(true)); await delegate.push(route); verify(() => navigatorState.push(route)); }); @@ -409,9 +424,12 @@ void main() { when(() => navigatorState.popUntil(any())).thenReturn(null); - delegate.currentConfiguration = ModularBook(routes: [route1, route2, route3]); + delegate.currentConfiguration = + ModularBook(routes: [route1, route2, route3]); - when(() => parser.selectBook('/pushForce2', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route3])); + when(() => parser.selectBook('/pushForce2', + popCallback: any(named: 'popCallback'))) + .thenAnswer((_) async => ModularBook(routes: [route3])); // ignore: unawaited_futures delegate.pushNamedAndRemoveUntil('/pushForce2', ModalRoute.withName('/')); await Future.delayed(const Duration(milliseconds: 400)); @@ -448,7 +466,9 @@ void main() { delegate.currentConfiguration = ModularBook(routes: [route1]); - when(() => parser.selectBook('/pushForce', popCallback: any(named: 'popCallback'))).thenAnswer((_) async => ModularBook(routes: [route2])); + when(() => parser.selectBook('/pushForce', + popCallback: any(named: 'popCallback'))) + .thenAnswer((_) async => ModularBook(routes: [route2])); // ignore: unawaited_futures delegate.pushNamedAndRemoveUntil('/pushForce', (_) => false, forRoot: true); await Future.delayed(const Duration(milliseconds: 400)); @@ -465,6 +485,9 @@ void main() { expect(() => route.opaque, throwsA(isA())); expect(() => route.transitionDuration, throwsA(isA())); expect(() => route.barrierLabel, throwsA(isA())); - expect(() => route.buildPage(BuildContextMock(), AnimationMock(), AnimationMock()), throwsA(isA())); + expect( + () => route.buildPage( + BuildContextMock(), AnimationMock(), AnimationMock()), + throwsA(isA())); }); } From 57413a5f3446eb41b20cec5a7830e14f064b322e Mon Sep 17 00:00:00 2001 From: Jacob Moura Date: Wed, 11 May 2022 21:11:49 -0300 Subject: [PATCH 8/8] fix: prepare publish --- plugins/modular_bloc_bind/LICENSE | 13 +++++++++++++ plugins/modular_bloc_bind/README.md | 2 +- plugins/modular_bloc_bind/example/pubspec.yaml | 2 +- plugins/modular_bloc_bind/pubspec.yaml | 12 ++++++------ plugins/modular_triple_bind/LICENSE | 13 +++++++++++++ plugins/modular_triple_bind/example/pubspec.yaml | 2 +- plugins/modular_triple_bind/pubspec.yaml | 12 ++++++------ 7 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 plugins/modular_bloc_bind/LICENSE create mode 100644 plugins/modular_triple_bind/LICENSE diff --git a/plugins/modular_bloc_bind/LICENSE b/plugins/modular_bloc_bind/LICENSE new file mode 100644 index 00000000..22d8ef64 --- /dev/null +++ b/plugins/modular_bloc_bind/LICENSE @@ -0,0 +1,13 @@ +The MIT License +License Copyright: Flutterando. +License License: Flutterando. +License Contact: Flutterando. +SPDX short identifier: MIT +Further resources... +  +Begin license text. +Copyright 2021 Flutterando +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +End license text. \ No newline at end of file diff --git a/plugins/modular_bloc_bind/README.md b/plugins/modular_bloc_bind/README.md index b4a45788..d41aa0ba 100644 --- a/plugins/modular_bloc_bind/README.md +++ b/plugins/modular_bloc_bind/README.md @@ -3,7 +3,7 @@ Working only Modular 5. -Specific Bind to BLoC with auto-dispose and notifier: +Specific Bind to BLoC with auto-dispose and selector: ```dart @override diff --git a/plugins/modular_bloc_bind/example/pubspec.yaml b/plugins/modular_bloc_bind/example/pubspec.yaml index 9e4819e4..e6fd30f3 100644 --- a/plugins/modular_bloc_bind/example/pubspec.yaml +++ b/plugins/modular_bloc_bind/example/pubspec.yaml @@ -30,7 +30,7 @@ dependencies: flutter: sdk: flutter bloc: ^8.0.3 - flutter_modular: 5.0.0-dev.8 + flutter_modular: 5.0.0 dartz: ^0.10.0-nullsafety.2 http: ^0.13.0 bloc_concurrency: ^0.2.0 diff --git a/plugins/modular_bloc_bind/pubspec.yaml b/plugins/modular_bloc_bind/pubspec.yaml index 0a0344d5..c02aade7 100644 --- a/plugins/modular_bloc_bind/pubspec.yaml +++ b/plugins/modular_bloc_bind/pubspec.yaml @@ -1,16 +1,16 @@ name: modular_bloc_bind -description: A starting point for Dart libraries or applications. -version: 1.0.0-dev.2 -# homepage: https://www.example.com +description: Smart project structure with dependency injection and route management +version: 1.0.0 +homepage: https://github.com/Flutterando/modular environment: - sdk: '>=2.15.1 <3.0.0' + sdk: '>=2.12.0 <3.0.0' dependencies: bloc: ^8.0.3 stream_transform: ^2.0.0 - flutter_modular: 5.0.0-dev.8 - modular_interfaces: 2.0.0-dev.11 + flutter_modular: ">=5.0.0 <6.0.0" + modular_interfaces: ">=2.0.0 <3.0.0" flutter: sdk: flutter diff --git a/plugins/modular_triple_bind/LICENSE b/plugins/modular_triple_bind/LICENSE new file mode 100644 index 00000000..22d8ef64 --- /dev/null +++ b/plugins/modular_triple_bind/LICENSE @@ -0,0 +1,13 @@ +The MIT License +License Copyright: Flutterando. +License License: Flutterando. +License Contact: Flutterando. +SPDX short identifier: MIT +Further resources... +  +Begin license text. +Copyright 2021 Flutterando +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +End license text. \ No newline at end of file diff --git a/plugins/modular_triple_bind/example/pubspec.yaml b/plugins/modular_triple_bind/example/pubspec.yaml index 887e8e62..ea4d361c 100644 --- a/plugins/modular_triple_bind/example/pubspec.yaml +++ b/plugins/modular_triple_bind/example/pubspec.yaml @@ -25,7 +25,7 @@ dependencies: flutter_mobx: ^2.0.1 flutter_triple: ^1.2.3+2 http: ^0.13.0 - flutter_modular: ^5.0.0-dev.8 + flutter_modular: ^5.0.0 alice: ^0.2.4 modular_triple_bind: path: ../ diff --git a/plugins/modular_triple_bind/pubspec.yaml b/plugins/modular_triple_bind/pubspec.yaml index b9b14482..4fffdcb4 100644 --- a/plugins/modular_triple_bind/pubspec.yaml +++ b/plugins/modular_triple_bind/pubspec.yaml @@ -1,16 +1,16 @@ name: modular_triple_bind -description: A starting point for Dart libraries or applications. -version: 1.0.0-dev.2 -# homepage: https://www.example.com +description: Smart project structure with dependency injection and route management +version: 1.0.0 +homepage: https://github.com/Flutterando/modular environment: - sdk: '>=2.15.1 <3.0.0' + sdk: '>=2.12.0 <3.0.0' dependencies: triple: '>=1.5.0 <2.0.0' - flutter_modular: 5.0.0-dev.8 - modular_interfaces: 2.0.0-dev.11 + flutter_modular: ">=5.0.0 <6.0.0" + modular_interfaces: ">=2.0.0 <3.0.0" flutter: sdk: flutter