From e9cf309a02825c772cba35cd2c5170ba7aa3441e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BChler?= Date: Tue, 7 May 2024 11:19:49 +0200 Subject: [PATCH] feat: use native navigation instead of getX navigation (#6) This removes get (getX) as the underlying navigation engine. Since GetX also routes with the native navigation stack, this can be directly used instead of passed to get which then in turn passes it to flutter. While doing this, the services were redesigned and all navigation related matters are now in the navigation service only. BREAKING CHANGE: The `DialogService` was deleted. Dialog related methods are now in the `NavigationService`. BREAKING CHANGE: The `BottomSheetService` was deleted. All related methods are now in the `NavigationService`. BREAKING CHANGE: the close methods for dialog and sheet (`closeDialog` and `closeSheet`) are removed. They are unified in the method `closeOverlay` in the `NavigationService`. BREAKING CHANGE: Since getX is removed, the base logic of the entry point in the app could be simplified. Instead of the key and observer being methods, they are now static initialized fields on the navigation service. BRAKING CHANGE: The `preventDuplicates` parameter for the navigation method is gone. Currently, with native navigation, the user of the package is responsible to have an overview of the navigation stack. --- packages/fluorflow/README.md | 12 +- packages/fluorflow/example/lib/main.dart | 2 +- .../example/lib/views/detail/detail_view.dart | 4 + .../lib/views/detail/detail_viewmodel.dart | 9 +- .../lib/views/home/home_viewmodel.dart | 5 +- packages/fluorflow/lib/fluorflow.dart | 2 - .../src/annotations/bottom_sheet_config.dart | 10 +- .../bottom_sheets/bottom_sheet_service.dart | 43 -- .../lib/src/dialogs/dialog_service.dart | 39 -- .../src/navigation/navigation_service.dart | 176 ++++++-- packages/fluorflow/pubspec.yaml | 1 - .../simple_bottom_sheet_test.dart | 126 ++++++ .../test/dialogs/simple_dialog_test.dart | 127 ++++++ packages/fluorflow/test/helpers.dart | 12 + ...ode_test.dart => data_viewmodel_test.dart} | 40 ++ packages/fluorflow_generator/README.md | 13 +- .../lib/src/builder/bottom_sheet_builder.dart | 21 +- .../lib/src/builder/dialog_builder.dart | 4 +- .../lib/src/builder/locator_builder.dart | 24 -- .../lib/src/builder/router_builder.dart | 17 +- .../lib/src/builder/test_locator_builder.dart | 14 - .../builder/bottom_sheet_builder_test.dart | 283 ++++++++----- .../test/builder/dialog_builder_test.dart | 120 +++--- .../test/builder/locator_builder_test.dart | 112 ----- .../test/builder/router_builder_test.dart | 396 ++++-------------- .../builder/test_locator_builder_test.dart | 327 +-------------- 26 files changed, 816 insertions(+), 1123 deletions(-) delete mode 100644 packages/fluorflow/lib/src/bottom_sheets/bottom_sheet_service.dart delete mode 100644 packages/fluorflow/lib/src/dialogs/dialog_service.dart create mode 100644 packages/fluorflow/test/bottom_sheets/simple_bottom_sheet_test.dart create mode 100644 packages/fluorflow/test/dialogs/simple_dialog_test.dart create mode 100644 packages/fluorflow/test/helpers.dart rename packages/fluorflow/test/viewmodels/{data_viewmode_test.dart => data_viewmodel_test.dart} (63%) diff --git a/packages/fluorflow/README.md b/packages/fluorflow/README.md index 7c11ea5..c9323f6 100644 --- a/packages/fluorflow/README.md +++ b/packages/fluorflow/README.md @@ -29,7 +29,7 @@ class MyApp extends StatelessWidget { initialRoute: AppRoute.homeView.path, onGenerateRoute: onGenerateRoute, navigatorKey: NavigationService.navigatorKey, - navigatorObservers: [NavigationService.observer()], + navigatorObservers: [NavigationService.observer], ); } } @@ -41,12 +41,12 @@ Especially the part for routing is important (if you use FluorFlow views and rou initialRoute: AppRoute.homeView.path, onGenerateRoute: onGenerateRoute, navigatorKey: NavigationService.navigatorKey, -navigatorObservers: [NavigationService.observer()], +navigatorObservers: [NavigationService.observer], ``` -This enables the routing system of FluorFlow (which uses GetX underneath). +This enables the routing system of FluorFlow. -The other parts of the material app can be as you wish. +The other parts of the app can be as you wish. ## Views @@ -176,12 +176,12 @@ final class GreetingBottomSheet extends FluorFlowSimpleBottomSheet { } ``` -Bottom sheets are shown via the `BottomSheetService` that has extension methods +Bottom sheets are shown via the `NavigationService` that has extension methods attached for each bottom sheet. Parameters of sheets are taken into account when used with the fluorflow generator. Dialogs work exactly the same way as bottom sheets, but are shown via the -`DialogService` and have another base class. +`Dialogs` extension in the `NavigationService` and have another base class. **Important:** Bottom sheets are always wrapped in a `Scaffold` widget. Thus, they inherit your styles. `Dialogs` do not have this behavior (by design). diff --git a/packages/fluorflow/example/lib/main.dart b/packages/fluorflow/example/lib/main.dart index 42c25e9..df43a5e 100644 --- a/packages/fluorflow/example/lib/main.dart +++ b/packages/fluorflow/example/lib/main.dart @@ -22,6 +22,6 @@ class MyApp extends StatelessWidget { initialRoute: AppRoute.homeView.path, onGenerateRoute: onGenerateRoute, navigatorKey: NavigationService.navigatorKey, - navigatorObservers: [NavigationService.observer()], + navigatorObservers: [NavigationService.observer], ); } diff --git a/packages/fluorflow/example/lib/views/detail/detail_view.dart b/packages/fluorflow/example/lib/views/detail/detail_view.dart index 0ff2f75..7b418df 100644 --- a/packages/fluorflow/example/lib/views/detail/detail_view.dart +++ b/packages/fluorflow/example/lib/views/detail/detail_view.dart @@ -36,6 +36,10 @@ final class DetailView extends FluorFlowView { onPressed: viewModel.back, child: const Text('Back'), ), + ElevatedButton( + onPressed: viewModel.rootBack, + child: const Text('Root to home view'), + ), ElevatedButton( onPressed: viewModel.showBottomSheet, child: const Text('Show Bottom Sheet'), diff --git a/packages/fluorflow/example/lib/views/detail/detail_viewmodel.dart b/packages/fluorflow/example/lib/views/detail/detail_viewmodel.dart index 7e8d33e..934c628 100644 --- a/packages/fluorflow/example/lib/views/detail/detail_viewmodel.dart +++ b/packages/fluorflow/example/lib/views/detail/detail_viewmodel.dart @@ -1,18 +1,19 @@ -import 'dart:async'; - import 'package:example/app.bottom_sheets.dart'; import 'package:fluorflow/fluorflow.dart'; +import '../../app.router.dart'; + final class DetailViewModel extends DataViewModel { final _navService = locator(); - final _sheets = locator(); DetailViewModel() : super(0); void showBottomSheet() => - _sheets.showGreetingBottomSheet(callback: () {}, onElement: (_) {}); + _navService.showGreetingBottomSheet(callback: () {}, onElement: (_) {}); void back() => _navService.back(); + void rootBack() => _navService.rootToHomeView(); + void addOne() => data += 1; } diff --git a/packages/fluorflow/example/lib/views/home/home_viewmodel.dart b/packages/fluorflow/example/lib/views/home/home_viewmodel.dart index 78bee07..21e8858 100644 --- a/packages/fluorflow/example/lib/views/home/home_viewmodel.dart +++ b/packages/fluorflow/example/lib/views/home/home_viewmodel.dart @@ -4,7 +4,6 @@ import '../../app.dialogs.dart'; import '../../app.router.dart'; final class HomeViewModel extends BaseViewModel { - final _dialogService = locator(); final _navService = locator(); var _counter = 0; @@ -16,9 +15,9 @@ final class HomeViewModel extends BaseViewModel { notifyListeners(); } - void showTestDialog() => _dialogService.showRedDialog(elements: []); + void showTestDialog() => _navService.showRedDialog(elements: []); - void showSmallDialog() => _dialogService.showSmallDialog(); + void showSmallDialog() => _navService.showSmallDialog(); void goToDetail() => _navService.navigateToDetailView(); } diff --git a/packages/fluorflow/lib/fluorflow.dart b/packages/fluorflow/lib/fluorflow.dart index 2d744e2..1b8953b 100644 --- a/packages/fluorflow/lib/fluorflow.dart +++ b/packages/fluorflow/lib/fluorflow.dart @@ -2,10 +2,8 @@ library fluorflow; export 'src/bottom_sheets/bottom_sheet.dart'; -export 'src/bottom_sheets/bottom_sheet_service.dart'; export 'src/bottom_sheets/simple_bottom_sheet.dart'; export 'src/dialogs/dialog.dart'; -export 'src/dialogs/dialog_service.dart'; export 'src/dialogs/simple_dialog.dart'; export 'src/locator/locator.dart'; export 'src/navigation/navigation_service.dart'; diff --git a/packages/fluorflow/lib/src/annotations/bottom_sheet_config.dart b/packages/fluorflow/lib/src/annotations/bottom_sheet_config.dart index 1057096..6c3191b 100644 --- a/packages/fluorflow/lib/src/annotations/bottom_sheet_config.dart +++ b/packages/fluorflow/lib/src/annotations/bottom_sheet_config.dart @@ -11,18 +11,22 @@ class BottomSheetConfig { /// If set to false, the bottom sheet will be displayed at the bottom third(-ish) of the screen. final bool defaultFullscreen; - /// Whether the bottom sheet should ignore the safe area and take up the entire screen. + /// Whether the bottom sheet should ignore or use the safe area and take up the entire screen. /// This is most likely used in combination with [defaultFullscreen]. - final bool defaultIgnoreSafeArea; + final bool defaultUseSafeArea; /// Whether the bottom sheet can be dragged by the user. final bool defaultDraggable; + /// Whether the bottom sheet should show a drag handle. + final bool defaultShowDragHandle; + /// Decorate a bottom sheet or simple bottomsheet with a [BottomSheetConfig]. const BottomSheetConfig({ this.defaultBarrierColor = 0x80000000, this.defaultFullscreen = false, - this.defaultIgnoreSafeArea = true, + this.defaultUseSafeArea = false, this.defaultDraggable = true, + this.defaultShowDragHandle = false, }); } diff --git a/packages/fluorflow/lib/src/bottom_sheets/bottom_sheet_service.dart b/packages/fluorflow/lib/src/bottom_sheets/bottom_sheet_service.dart deleted file mode 100644 index 5945e66..0000000 --- a/packages/fluorflow/lib/src/bottom_sheets/bottom_sheet_service.dart +++ /dev/null @@ -1,43 +0,0 @@ -import 'dart:ui'; - -import 'package:get/get.dart'; - -import '../overlays/overlay.dart'; - -/// A service for showing and closing bottom sheets. -/// Works with [FluorFlowOverlay] instances. -class BottomSheetService { - /// Returns whether a bottom sheet is currently open. - bool get isDialogOpen => Get.isBottomSheetOpen ?? false; - - /// Shows a bottom sheet and returns a future with the result. - /// Use the convenience methods generated by the generator to show a bottom sheet - /// and return the result in an easy way. - /// - /// - [sheet] marks the sheet that is opened. - /// - [barrierColor] configures the color that is used behind the bottom sheet - /// if a portion of the screen is still visible. - /// - [fullscreen] configures whether the bottom sheet should take up the entire screen. If true, the [barrierColor] - /// is still applied, but may not be visible. - /// - [draggable] defines if the bottom sheet can be closed by dragging it down towards the bottom. - /// - [ignoreSafeArea] allows the bottom sheet to ignore [SafeArea] widgets and always uses the whole - /// screen if possible. This is most likely used in combination with [fullscreen]. - Future showBottomSheet( - TSheet sheet, { - Color barrierColor = const Color(0x80000000), - bool fullscreen = false, - bool draggable = true, - bool ignoreSafeArea = true, - }) => - Get.bottomSheet( - sheet, - barrierColor: barrierColor, - isScrollControlled: fullscreen, - enableDrag: draggable, - ignoreSafeArea: ignoreSafeArea, - ); - - /// Closes the currently open bottom sheet. - void closeSheet({bool? confirmed, T? result}) => - Get.back(result: (confirmed, result)); -} diff --git a/packages/fluorflow/lib/src/dialogs/dialog_service.dart b/packages/fluorflow/lib/src/dialogs/dialog_service.dart deleted file mode 100644 index d5c8766..0000000 --- a/packages/fluorflow/lib/src/dialogs/dialog_service.dart +++ /dev/null @@ -1,39 +0,0 @@ -import 'dart:math'; - -import 'package:flutter/widgets.dart'; -import 'package:get/get.dart'; - -/// A service for showing and closing dialogs. -/// Works with route builders. However, it is recommended to use the -/// convenience methods generated by the generator to show a dialog. -class DialogService { - final _random = Random(); - - /// Returns whether a dialog is currently open. - bool get isDialogOpen => Get.isDialogOpen ?? false; - - /// Shows a dialog and returns a future with the (possible) result. - /// - /// - The [barrierColor] parameter can be used to specify a custom barrier color for the dialog. - /// - The [barrierDismissible] parameter specifies whether the dialog can be dismissed by - /// tapping the barrier (if it is visible). - Future showDialog({ - required PageRouteBuilder dialogBuilder, - Color barrierColor = const Color(0x80000000), - bool barrierDismissible = false, - }) => - Get.generalDialog( - barrierDismissible: barrierDismissible, - barrierLabel: - barrierDismissible ? 'dialog_${_random.nextInt(1000000)}' : null, - pageBuilder: dialogBuilder.pageBuilder, - barrierColor: barrierColor, - transitionDuration: dialogBuilder.transitionDuration, - routeSettings: dialogBuilder.settings, - transitionBuilder: dialogBuilder.transitionsBuilder, - ); - - /// Closes the currently open dialog. - void closeDialog({bool? confirmed, T? result}) => - Get.back(result: (confirmed, result)); -} diff --git a/packages/fluorflow/lib/src/navigation/navigation_service.dart b/packages/fluorflow/lib/src/navigation/navigation_service.dart index b28f767..321d804 100644 --- a/packages/fluorflow/lib/src/navigation/navigation_service.dart +++ b/packages/fluorflow/lib/src/navigation/navigation_service.dart @@ -1,5 +1,6 @@ -import 'package:flutter/widgets.dart'; -import 'package:get/get.dart'; +import 'package:flutter/material.dart'; + +import '../overlays/overlay.dart'; /// A service that provides a set of methods to navigate between routes. /// One may directly use the [navigateTo] and other methods to navigate dynamically. @@ -32,37 +33,40 @@ import 'package:get/get.dart'; /// initialRoute: AppRoute.homeView.path, /// onGenerateRoute: onGenerateRoute, /// navigatorKey: NavigationService.navigatorKey, -/// navigatorObservers: [NavigationService.observer()], +/// navigatorObservers: [NavigationService.observer], /// ); /// } /// } /// ``` class NavigationService { + static final _navigator = _NavigationObserver(); + /// Static navigator key to be used in the main entrypoint of the app. /// This allows navigation without context of the build method. - static GlobalKey get navigatorKey => Get.key; + static final GlobalKey navigatorKey = + GlobalKey(debugLabel: 'Default Root Navigator Key'); /// Static navigator observer to be used in the main entrypoint of the app. /// Required for adjusting the navigation stack. - static NavigatorObserver observer() => GetObserver(null, Get.routing); + static final NavigatorObserver observer = _navigator; - /// Returns the previous route name. - String get previousRoute => Get.previousRoute; + const NavigationService(); - /// Returns the current route name. - String get currentRoute => Get.currentRoute; + /// Returns the current route name (or an empty string if no route + /// matches). + String get currentRoute => _navigator.currentRoute?.settings.name ?? ''; /// Returns the current route arguments (`dynamic` typed). - dynamic get currentArguments => Get.arguments; - - /// Returns the current route arguments (`T` typed). - T typedArguments() => Get.arguments; + dynamic get currentArguments => _navigator.currentRoute?.settings.arguments; /// Navigate "back" and return an optional result. - void back({T? result}) => Get.back(result: result); + void back([T? result]) => navigatorKey.currentState?.canPop() == true + ? navigatorKey.currentState!.pop(result) + : null; /// Pops the route stack until the predicate is fulfilled. - void popUntil(RoutePredicate predicate) => Get.until(predicate); + void popUntil(RoutePredicate predicate) => + navigatorKey.currentState?.popUntil(predicate); /// Navigate to a new route and return an optional result /// when back is called from the new route. This pushes @@ -70,30 +74,18 @@ class NavigationService { Future? navigateTo( String routeName, { dynamic arguments, - bool preventDuplicates = true, - Map? parameters, }) => - Get.toNamed( - routeName, - arguments: arguments, - preventDuplicates: preventDuplicates, - parameters: parameters, - ); + navigatorKey.currentState?.pushNamed(routeName, arguments: arguments); /// Navigate to a new route and replace the current route on the /// navigation stack. void replaceWith( String routeName, { dynamic arguments, - bool preventDuplicates = true, - Map? parameters, - RouteTransitionsBuilder? transition, }) => - Get.offNamed( + navigatorKey.currentState?.pushReplacementNamed( routeName, arguments: arguments, - preventDuplicates: preventDuplicates, - parameters: parameters, ); /// Navigate to a new route and remove all previous routes from the @@ -101,11 +93,131 @@ class NavigationService { void rootTo( String routeName, { dynamic arguments, - Map? parameters, }) => - Get.offAllNamed( + navigatorKey.currentState?.pushNamedAndRemoveUntil( routeName, + (route) => false, arguments: arguments, - parameters: parameters, ); + + Future showDialog({ + required PageRouteBuilder dialogBuilder, + Color barrierColor = const Color(0x80000000), + bool barrierDismissible = false, + }) { + if (navigatorKey.currentState?.overlay == null) { + return Future.value(null); + } + + return Navigator.of(navigatorKey.currentState!.overlay!.context, + rootNavigator: true) + .push(_DialogRoute( + dialogBuilder: dialogBuilder, + barrierColor: barrierColor, + barrierDismissible: barrierDismissible, + )); + } + + Future showBottomSheet( + TSheet sheet, { + Color barrierColor = const Color(0x80000000), + bool useRootNavigator = false, + bool fullscreen = false, + bool draggable = true, + bool showDragHandle = false, + bool useSafeArea = false, + }) { + if (navigatorKey.currentState?.overlay == null) { + return Future.value(null); + } + + return Navigator.of(navigatorKey.currentState!.overlay!.context, + rootNavigator: useRootNavigator) + .push(ModalBottomSheetRoute( + builder: (context) => sheet, + isScrollControlled: fullscreen, + enableDrag: draggable, + showDragHandle: showDragHandle, + modalBarrierColor: barrierColor, + useSafeArea: useSafeArea, + )); + } + + void closeOverlay({bool? confirmed, T? result}) { + if (navigatorKey.currentState == null) { + return; + } + + Navigator.of(navigatorKey.currentState!.overlay!.context, + rootNavigator: true) + .pop((confirmed, result)); + } +} + +final class _DialogRoute extends PopupRoute { + final PageRouteBuilder dialogBuilder; + + @override + final Color barrierColor; + + @override + final bool barrierDismissible; + + _DialogRoute({ + required this.dialogBuilder, + required this.barrierColor, + required this.barrierDismissible, + }); + + @override + String? get barrierLabel => barrierDismissible + ? 'dialog ${dialogBuilder.settings.name} $hashCode' + : null; + + @override + Widget buildPage(BuildContext context, Animation animation, + Animation secondaryAnimation) => + dialogBuilder.buildPage(context, animation, secondaryAnimation); + + @override + Widget buildTransitions(BuildContext context, Animation animation, + Animation secondaryAnimation, Widget child) => + dialogBuilder.buildTransitions( + context, animation, secondaryAnimation, child); + + @override + Duration get transitionDuration => dialogBuilder.transitionDuration; + + @override + Duration get reverseTransitionDuration => + dialogBuilder.reverseTransitionDuration; +} + +final class _NavigationObserver extends NavigatorObserver { + final _history = List>.empty(growable: true); + + Route? get currentRoute => + _history.where((r) => r.isCurrent).firstOrNull; + + @override + void didPush(Route route, Route? previousRoute) => + _history.add(route); + + @override + void didPop(Route route, Route? previousRoute) => + _history.remove(route); + + @override + void didRemove(Route route, Route? previousRoute) => + _history.remove(route); + + @override + void didReplace({Route? newRoute, Route? oldRoute}) { + if (oldRoute != null) { + _history.remove(oldRoute); + } + if (newRoute != null) { + _history.add(newRoute); + } + } } diff --git a/packages/fluorflow/pubspec.yaml b/packages/fluorflow/pubspec.yaml index 329baac..9be5a86 100644 --- a/packages/fluorflow/pubspec.yaml +++ b/packages/fluorflow/pubspec.yaml @@ -14,7 +14,6 @@ dependencies: dart_style: ^2.0.0 flutter: sdk: flutter - get: ^4.0.0 get_it: ^7.0.0 path: ^1.0.0 recase: ^4.0.0 diff --git a/packages/fluorflow/test/bottom_sheets/simple_bottom_sheet_test.dart b/packages/fluorflow/test/bottom_sheets/simple_bottom_sheet_test.dart new file mode 100644 index 0000000..8f5afc4 --- /dev/null +++ b/packages/fluorflow/test/bottom_sheets/simple_bottom_sheet_test.dart @@ -0,0 +1,126 @@ +import 'package:fluorflow/fluorflow.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import '../helpers.dart'; + +final class _BottomSheet extends FluorFlowSimpleBottomSheet { + const _BottomSheet({required super.completer}); + + @override + Widget build(BuildContext context) => Row( + mainAxisSize: MainAxisSize.min, + children: [ + Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('Bottom Sheet'), + TextButton( + onPressed: completer.confirm, + child: const Text('confirm'), + ), + TextButton( + onPressed: completer.cancel, + child: const Text('cancel'), + ), + TextButton( + onPressed: completer.abort, + child: const Text('abort'), + ), + ], + ), + ], + ); +} + +final class _TestView extends StatefulWidget { + @override + State<_TestView> createState() => _TestViewState(); +} + +class _TestViewState extends State<_TestView> { + final _nav = const NavigationService(); + bool? _result; + + @override + Widget build(BuildContext context) => Column( + children: [ + TextButton( + onPressed: () async { + final result = + await _nav.showBottomSheet<(bool?, dynamic), _BottomSheet>( + _BottomSheet(completer: _nav.closeOverlay), + ); + setState(() => _result = result?.$1); + }, + child: const Text('open')), + Text(_result?.toString() ?? 'null'), + ], + ); +} + +void main() { + group('FluorFlowSimpleBottomSheet', () { + testWidgets('should open via navigation service.', (tester) async { + await tester.pumpWidget(mockApp(_TestView())); + await tester.pumpAndSettle(); + + await tester.tap(find.text('open')); + await tester.pumpAndSettle(); + + expect(find.text('Bottom Sheet'), findsOneWidget); + }); + + testWidgets('should confirm on close.', (tester) async { + await tester.pumpWidget(mockApp(_TestView())); + await tester.pumpAndSettle(); + + await tester.tap(find.text('open')); + await tester.pumpAndSettle(); + + await tester.tap(find.text('confirm')); + await tester.pumpAndSettle(); + + expect(find.text('true'), findsOneWidget); + }); + + testWidgets('should cancel (not confirmed) on close.', (tester) async { + await tester.pumpWidget(mockApp(_TestView())); + await tester.pumpAndSettle(); + + await tester.tap(find.text('open')); + await tester.pumpAndSettle(); + + await tester.tap(find.text('cancel')); + await tester.pumpAndSettle(); + + expect(find.text('false'), findsOneWidget); + }); + + testWidgets('should return null on abort.', (tester) async { + await tester.pumpWidget(mockApp(_TestView())); + await tester.pumpAndSettle(); + + await tester.tap(find.text('open')); + await tester.pumpAndSettle(); + + await tester.tap(find.text('abort')); + await tester.pumpAndSettle(); + + expect(find.text('null'), findsOneWidget); + }); + + testWidgets('should abort on barrier click.', (tester) async { + await tester.pumpWidget(mockApp(_TestView())); + await tester.pumpAndSettle(); + + await tester.tap(find.text('open')); + await tester.pumpAndSettle(); + + await tester.tap(find.byType(_TestView), warnIfMissed: false); + await tester.pumpAndSettle(); + + expect(find.text('null'), findsOneWidget); + }); + }); +} diff --git a/packages/fluorflow/test/dialogs/simple_dialog_test.dart b/packages/fluorflow/test/dialogs/simple_dialog_test.dart new file mode 100644 index 0000000..2cf619e --- /dev/null +++ b/packages/fluorflow/test/dialogs/simple_dialog_test.dart @@ -0,0 +1,127 @@ +import 'package:fluorflow/fluorflow.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import '../helpers.dart'; + +final class _Dialog extends FluorFlowSimpleDialog { + const _Dialog({required super.completer}); + + @override + Widget build(BuildContext context) => Row( + mainAxisSize: MainAxisSize.min, + children: [ + Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Text('Dialog'), + TextButton( + onPressed: completer.confirm, + child: const Text('confirm'), + ), + TextButton( + onPressed: completer.cancel, + child: const Text('cancel'), + ), + TextButton( + onPressed: completer.abort, + child: const Text('abort'), + ), + ], + ), + ], + ); +} + +final class _TestView extends StatefulWidget { + @override + State<_TestView> createState() => _TestViewState(); +} + +class _TestViewState extends State<_TestView> { + final _nav = const NavigationService(); + bool? _result; + + @override + Widget build(BuildContext context) => Column( + children: [ + TextButton( + onPressed: () async { + final result = await _nav.showDialog<(bool?, dynamic)>( + dialogBuilder: NoTransitionPageRouteBuilder( + pageBuilder: (_, __, ___) => + _Dialog(completer: _nav.closeOverlay)), + ); + setState(() => _result = result?.$1); + }, + child: const Text('open')), + Text(_result?.toString() ?? 'null'), + ], + ); +} + +void main() { + group('FluorFlowSimpleDialog', () { + testWidgets('should open via navigation service.', (tester) async { + await tester.pumpWidget(mockApp(_TestView())); + await tester.pumpAndSettle(); + + await tester.tap(find.text('open')); + await tester.pumpAndSettle(); + + expect(find.text('Dialog'), findsOneWidget); + }); + + testWidgets('should confirm on close.', (tester) async { + await tester.pumpWidget(mockApp(_TestView())); + await tester.pumpAndSettle(); + + await tester.tap(find.text('open')); + await tester.pumpAndSettle(); + + await tester.tap(find.text('confirm')); + await tester.pumpAndSettle(); + + expect(find.text('true'), findsOneWidget); + }); + + testWidgets('should cancel (not confirmed) on close.', (tester) async { + await tester.pumpWidget(mockApp(_TestView())); + await tester.pumpAndSettle(); + + await tester.tap(find.text('open')); + await tester.pumpAndSettle(); + + await tester.tap(find.text('cancel')); + await tester.pumpAndSettle(); + + expect(find.text('false'), findsOneWidget); + }); + + testWidgets('should return null on abort.', (tester) async { + await tester.pumpWidget(mockApp(_TestView())); + await tester.pumpAndSettle(); + + await tester.tap(find.text('open')); + await tester.pumpAndSettle(); + + await tester.tap(find.text('abort')); + await tester.pumpAndSettle(); + + expect(find.text('null'), findsOneWidget); + }); + + testWidgets('should abort on barrier click.', (tester) async { + await tester.pumpWidget(mockApp(_TestView())); + await tester.pumpAndSettle(); + + await tester.tap(find.text('open')); + await tester.pumpAndSettle(); + + await tester.tap(find.byType(_TestView), warnIfMissed: false); + await tester.pumpAndSettle(); + + expect(find.text('null'), findsOneWidget); + }); + }); +} diff --git a/packages/fluorflow/test/helpers.dart b/packages/fluorflow/test/helpers.dart new file mode 100644 index 0000000..92b1f1b --- /dev/null +++ b/packages/fluorflow/test/helpers.dart @@ -0,0 +1,12 @@ +import 'package:fluorflow/fluorflow.dart'; +import 'package:flutter/material.dart'; + +Widget mockApp( + Widget child, { + bool withScaffold = true, +}) => + MaterialApp( + navigatorKey: NavigationService.navigatorKey, + navigatorObservers: [NavigationService.observer], + home: withScaffold ? Scaffold(body: child) : child, + ); diff --git a/packages/fluorflow/test/viewmodels/data_viewmode_test.dart b/packages/fluorflow/test/viewmodels/data_viewmodel_test.dart similarity index 63% rename from packages/fluorflow/test/viewmodels/data_viewmode_test.dart rename to packages/fluorflow/test/viewmodels/data_viewmodel_test.dart index f809d7b..b45cd65 100644 --- a/packages/fluorflow/test/viewmodels/data_viewmode_test.dart +++ b/packages/fluorflow/test/viewmodels/data_viewmodel_test.dart @@ -1,8 +1,12 @@ import 'dart:async'; import 'package:fluorflow/src/viewmodels/data_viewmodel.dart'; +import 'package:fluorflow/src/views/fluorflow_view.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; +import '../helpers.dart'; + final class _NormalViewModel extends DataViewModel { _NormalViewModel() : super('Hello, World!'); @@ -11,6 +15,8 @@ final class _NormalViewModel extends DataViewModel { data = 'Hello, brave new World!'; return super.initialize(); } + + void updateData() => data = 'Updated!'; } final class _ErrorViewModel extends DataViewModel { @@ -28,6 +34,22 @@ final class _ErrorViewModel extends DataViewModel { } } +final class _TestView extends FluorFlowView<_NormalViewModel> { + @override + Widget builder( + BuildContext context, _NormalViewModel viewModel, Widget? child) => + Column( + children: [ + Text(viewModel.data), + TextButton( + onPressed: viewModel.updateData, child: const Text('update')), + ], + ); + + @override + _NormalViewModel viewModelBuilder(BuildContext context) => _NormalViewModel(); +} + void main() { group('DataViewModel', () { test('should set the provided initial data.', () async { @@ -67,5 +89,23 @@ void main() { await viewModel.initialize(); expect(viewModel.error, isA()); }); + + testWidgets('should show initial data on view.', (tester) async { + await tester.pumpWidget(mockApp(_TestView())); + await tester.pumpAndSettle(); + + expect(find.text('Hello, brave new World!'), findsOneWidget); + }); + + testWidgets('should update ui after data change.', (tester) async { + await tester.pumpWidget(mockApp(_TestView())); + await tester.pumpAndSettle(); + + await tester.tap(find.text('update')); + + await tester.pumpAndSettle(); + + expect(find.text('Updated!'), findsOneWidget); + }); }); } diff --git a/packages/fluorflow_generator/README.md b/packages/fluorflow_generator/README.md index c91aada..c89d105 100644 --- a/packages/fluorflow_generator/README.md +++ b/packages/fluorflow_generator/README.md @@ -48,16 +48,12 @@ global_options: - `output` (String): The file path for the generated locator file. Default: `lib/app.locator.dart`. - `emitAllReady` (bool): Whether to emit the `await allReady()` method call in the locator setup method. Default: `true`. - `register_services`: Whether to register services in the locator. - - `bottomSheet` (bool): Whether to register the bottom sheet service. Default: `true`. - - `dialog` (bool): Whether to register the dialog service. Default: `true`. - `navigation` (bool): Whether to register the navigation service. Default: `true`. ### Test Locator Options - `output` (String): The file path for the generated locator file. Default: `test/test.locator.dart`. - `register_services`: Whether to register services in the locator. - - `bottomSheet` (bool): Whether to register the mock bottom sheet service. Default: `true`. - - `dialog` (bool): Whether to register the mock dialog service. Default: `true`. - `navigation` (bool): Whether to register the mock navigation service. Default: `true`. ### Router Options @@ -76,7 +72,7 @@ global_options: Currently the following generators are supported: -- Dependency Injection +- Dependency Injection (For services and test services) - Routing - Dialogs - Bottom Sheets @@ -133,13 +129,12 @@ Both of these work the same way. You just extend the `FluorFlowDialog`, `FluorFl `FluorFlowBottomSheet` or `FluorFlowSimpleBottomSheet` classes. There are special annotations for configuration of the generated code - if needed. -When such extended classes are found, method extensions for the `DialogService` respectively -`BottomSheetService` are generated. +When such extended classes are found, method extensions for the `NavigationService` are generated. An example of such a dialog method: ```dart -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, int?)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), }) => @@ -152,7 +147,7 @@ extension Dialogs on _i1.DialogService { ___, ) => _i4.MyDialog( - completer: closeDialog, + completer: closeOverlay, )), ).then((r) => (r?.$1, r?.$2)); } diff --git a/packages/fluorflow_generator/lib/src/builder/bottom_sheet_builder.dart b/packages/fluorflow_generator/lib/src/builder/bottom_sheet_builder.dart index da5cb0c..e112071 100644 --- a/packages/fluorflow_generator/lib/src/builder/bottom_sheet_builder.dart +++ b/packages/fluorflow_generator/lib/src/builder/bottom_sheet_builder.dart @@ -33,7 +33,7 @@ class BottomSheetBuilder implements Builder { var extension = Extension((b) => b ..name = 'BottomSheets' - ..on = refer('BottomSheetService', 'package:fluorflow/fluorflow.dart')); + ..on = refer('NavigationService', 'package:fluorflow/fluorflow.dart')); await for (final assetId in buildStep.findAssets(_allDartFilesInLib)) { if (!await resolver.isLibrary(assetId)) { @@ -92,12 +92,12 @@ class BottomSheetBuilder implements Builder { false) .code)) ..optionalParameters.add(Parameter((b) => b - ..name = 'ignoreSafeArea' + ..name = 'useSafeArea' ..type = refer('bool') ..named = true ..defaultTo = literalBool( - configAnnotation?.read('defaultIgnoreSafeArea').boolValue ?? - true) + configAnnotation?.read('defaultUseSafeArea').boolValue ?? + false) .code)) ..optionalParameters.add(Parameter((b) => b ..name = 'draggable' @@ -107,6 +107,14 @@ class BottomSheetBuilder implements Builder { configAnnotation?.read('defaultDraggable').boolValue ?? true) .code)) + ..optionalParameters.add(Parameter((b) => b + ..name = 'showDragHandle' + ..type = refer('bool') + ..named = true + ..defaultTo = literalBool( + configAnnotation?.read('defaultShowDragHandle').boolValue ?? + false) + .code)) ..optionalParameters.addAll(params.map((p) => Parameter((b) => b ..name = p.name ..type = recursiveTypeReference(lib, p.type) @@ -121,7 +129,7 @@ class BottomSheetBuilder implements Builder { .where((p) => p.isPositional) .map((p) => refer(p.name)), { - 'completer': refer('closeSheet'), + 'completer': refer('closeOverlay'), for (final p in params.where((p) => p.isNamed)) p.name: refer(p.name) }), @@ -129,7 +137,8 @@ class BottomSheetBuilder implements Builder { 'barrierColor': refer('barrierColor'), 'fullscreen': refer('fullscreen'), 'draggable': refer('draggable'), - 'ignoreSafeArea': refer('ignoreSafeArea'), + 'showDragHandle': refer('showDragHandle'), + 'useSafeArea': refer('useSafeArea'), }, [ methodTupleRef, refer(sheetClass.displayName, assetId.uri.toString()), diff --git a/packages/fluorflow_generator/lib/src/builder/dialog_builder.dart b/packages/fluorflow_generator/lib/src/builder/dialog_builder.dart index d0b440d..10935ca 100644 --- a/packages/fluorflow_generator/lib/src/builder/dialog_builder.dart +++ b/packages/fluorflow_generator/lib/src/builder/dialog_builder.dart @@ -34,7 +34,7 @@ class DialogBuilder implements Builder { var extension = Extension((b) => b ..name = 'Dialogs' - ..on = refer('DialogService', 'package:fluorflow/fluorflow.dart')); + ..on = refer('NavigationService', 'package:fluorflow/fluorflow.dart')); await for (final assetId in buildStep.findAssets(_allDartFilesInLib)) { if (!await resolver.isLibrary(assetId)) { @@ -140,7 +140,7 @@ class DialogBuilder implements Builder { .where((p) => p.isPositional) .map((p) => refer(p.name)), { - 'completer': refer('closeDialog'), + 'completer': refer('closeOverlay'), for (final p in params.where((p) => p.isNamed)) p.name: refer(p.name) }).code).closure diff --git a/packages/fluorflow_generator/lib/src/builder/locator_builder.dart b/packages/fluorflow_generator/lib/src/builder/locator_builder.dart index d3bae26..31a8ff0 100644 --- a/packages/fluorflow_generator/lib/src/builder/locator_builder.dart +++ b/packages/fluorflow_generator/lib/src/builder/locator_builder.dart @@ -17,11 +17,6 @@ extension on BuilderOptions { config['register_services'] ?? {}; bool get registerNavigationService => registerServices['navigation'] ?? true; - - bool get registerDialogService => registerServices['dialog'] ?? true; - - bool get registerBottomSheetService => - registerServices['bottomSheet'] ?? true; } class LocatorBuilder implements Builder { @@ -87,25 +82,6 @@ class LocatorBuilder implements Builder { ]))); } - if (options.registerDialogService) { - setupLocatorBlock = setupLocatorBlock.rebuild((b) => b - ..addExpression(locatorRef.property('registerLazySingleton').call([ - Method((b) => b - ..body = refer('DialogService', 'package:fluorflow/fluorflow.dart') - .newInstance([]).code).closure, - ]))); - } - - if (options.registerBottomSheetService) { - setupLocatorBlock = setupLocatorBlock.rebuild((b) => b - ..addExpression(locatorRef.property('registerLazySingleton').call([ - Method((b) => b - ..body = - refer('BottomSheetService', 'package:fluorflow/fluorflow.dart') - .newInstance([]).code).closure, - ]))); - } - if (setupLocatorBlock.statements.isEmpty) { return; } diff --git a/packages/fluorflow_generator/lib/src/builder/router_builder.dart b/packages/fluorflow_generator/lib/src/builder/router_builder.dart index e4f9677..9b9433e 100644 --- a/packages/fluorflow_generator/lib/src/builder/router_builder.dart +++ b/packages/fluorflow_generator/lib/src/builder/router_builder.dart @@ -116,7 +116,6 @@ class RouterBuilder implements Builder { prefix: 'rootTo', displayName: element.displayName, params: params, - withPreventDuplicates: false, withReturnFuture: false); } @@ -214,8 +213,7 @@ class RouterBuilder implements Builder { {required String prefix, required String displayName, required Iterable params, - bool withReturnFuture = true, - bool withPreventDuplicates = true}) => + bool withReturnFuture = true}) => ext.rebuild((b) => b ..methods.add(Method((b) => b ..name = '$prefix${displayName.pascalCase}' @@ -229,22 +227,9 @@ class RouterBuilder implements Builder { ..required = p.isRequired ..defaultTo = p.hasDefaultValue ? Code(p.defaultValueCode!) : null ..named = true))) - ..optionalParameters.addAll([ - if (withPreventDuplicates) - Parameter((b) => b - ..name = 'preventDuplicates' - ..type = refer('bool') - ..named = true - ..defaultTo = literalTrue.code), - ]) ..body = refer(prefix).call([ refer('AppRoute.${displayName.camelCase}.path'), ], { - ...withPreventDuplicates - ? { - 'preventDuplicates': refer('preventDuplicates'), - } - : {}, ...params.isNotEmpty ? { 'arguments': refer('${displayName.pascalCase}Arguments') diff --git a/packages/fluorflow_generator/lib/src/builder/test_locator_builder.dart b/packages/fluorflow_generator/lib/src/builder/test_locator_builder.dart index 6dfeb28..5d2974c 100644 --- a/packages/fluorflow_generator/lib/src/builder/test_locator_builder.dart +++ b/packages/fluorflow_generator/lib/src/builder/test_locator_builder.dart @@ -16,10 +16,6 @@ extension on BuilderOptions { Map get services => config['services'] ?? {}; bool get mockNavService => services['navigation'] ?? true; - - bool get mockDialogService => services['dialog'] ?? true; - - bool get mockBottomSheetService => services['bottomSheet'] ?? true; } class TestLocatorBuilder implements Builder { @@ -161,16 +157,6 @@ class TestLocatorBuilder implements Builder { refer('NavigationService', 'package:fluorflow/fluorflow.dart')); } - if (options.mockDialogService) { - addInternalType( - refer('DialogService', 'package:fluorflow/fluorflow.dart')); - } - - if (options.mockBottomSheetService) { - addInternalType( - refer('BottomSheetService', 'package:fluorflow/fluorflow.dart')); - } - setupTestLocatorMethod = setupTestLocatorMethod.rebuild((b) => b ..body = setupTestLocatorMethodBody ..annotations.add( diff --git a/packages/fluorflow_generator/test/builder/bottom_sheet_builder_test.dart b/packages/fluorflow_generator/test/builder/bottom_sheet_builder_test.dart index 281a0b4..2333d12 100644 --- a/packages/fluorflow_generator/test/builder/bottom_sheet_builder_test.dart +++ b/packages/fluorflow_generator/test/builder/bottom_sheet_builder_test.dart @@ -42,19 +42,21 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, dynamic)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, }) => showBottomSheet<(bool?, dynamic), _i3.MySheet>( - _i3.MySheet(completer: closeSheet), + _i3.MySheet(completer: closeOverlay), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -84,19 +86,21 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, void)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, }) => showBottomSheet<(bool?, void), _i3.MySheet>( - _i3.MySheet(completer: closeSheet), + _i3.MySheet(completer: closeOverlay), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, null)); } ''' @@ -126,19 +130,21 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, String?)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, }) => showBottomSheet<(bool?, String?), _i3.MySheet>( - _i3.MySheet(completer: closeSheet), + _i3.MySheet(completer: closeOverlay), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -174,19 +180,21 @@ import 'package:a/a.dart' as _i4; import 'package:a/b.dart' as _i2; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, _i2.DialogResultType?)> showMySheet({ _i3.Color barrierColor = const _i3.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, }) => showBottomSheet<(bool?, _i2.DialogResultType?), _i4.MySheet>( - _i4.MySheet(completer: closeSheet), + _i4.MySheet(completer: closeOverlay), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -218,19 +226,21 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, dynamic)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, }) => showBottomSheet<(bool?, dynamic), _i3.MySheet>( - _i3.MySheet(completer: closeSheet), + _i3.MySheet(completer: closeOverlay), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -260,19 +270,21 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, void)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, }) => showBottomSheet<(bool?, void), _i3.MySheet>( - _i3.MySheet(completer: closeSheet), + _i3.MySheet(completer: closeOverlay), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, null)); } ''' @@ -302,19 +314,21 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, String?)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, }) => showBottomSheet<(bool?, String?), _i3.MySheet>( - _i3.MySheet(completer: closeSheet), + _i3.MySheet(completer: closeOverlay), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -350,19 +364,21 @@ import 'package:a/a.dart' as _i4; import 'package:a/b.dart' as _i2; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, _i2.DialogResultType?)> showMySheet({ _i3.Color barrierColor = const _i3.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, }) => showBottomSheet<(bool?, _i2.DialogResultType?), _i4.MySheet>( - _i4.MySheet(completer: closeSheet), + _i4.MySheet(completer: closeOverlay), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -395,23 +411,25 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, dynamic)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, required String pos, }) => showBottomSheet<(bool?, dynamic), _i3.MySheet>( _i3.MySheet( pos, - completer: closeSheet, + completer: closeOverlay, ), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -442,23 +460,25 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, dynamic)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, required String? pos, }) => showBottomSheet<(bool?, dynamic), _i3.MySheet>( _i3.MySheet( pos, - completer: closeSheet, + completer: closeOverlay, ), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -489,23 +509,25 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, dynamic)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, required String pos, }) => showBottomSheet<(bool?, dynamic), _i3.MySheet>( _i3.MySheet( - completer: closeSheet, + completer: closeOverlay, pos: pos, ), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -536,23 +558,25 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, dynamic)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, String? pos, }) => showBottomSheet<(bool?, dynamic), _i3.MySheet>( _i3.MySheet( - completer: closeSheet, + completer: closeOverlay, pos: pos, ), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -583,23 +607,25 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, dynamic)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, String pos = 'default', }) => showBottomSheet<(bool?, dynamic), _i3.MySheet>( _i3.MySheet( - completer: closeSheet, + completer: closeOverlay, pos: pos, ), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -636,23 +662,25 @@ import 'package:a/a.dart' as _i4; import 'package:a/b.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, dynamic)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, required _i3.MySheetRef pos, }) => showBottomSheet<(bool?, dynamic), _i4.MySheet>( _i4.MySheet( - completer: closeSheet, + completer: closeOverlay, pos: pos, ), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -685,23 +713,25 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, dynamic)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, required List pos, }) => showBottomSheet<(bool?, dynamic), _i3.MySheet>( _i3.MySheet( pos, - completer: closeSheet, + completer: closeOverlay, ), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -734,23 +764,25 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, dynamic)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, required List<_i3.Foobar> pos, }) => showBottomSheet<(bool?, dynamic), _i3.MySheet>( _i3.MySheet( pos, - completer: closeSheet, + completer: closeOverlay, ), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -789,23 +821,25 @@ import 'package:a/a.dart' as _i3; import 'package:a/b.dart' as _i4; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, dynamic)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, required _i3.Foo<_i3.Bar<_i4.Baz, int>> pos, }) => showBottomSheet<(bool?, dynamic), _i3.MySheet>( _i3.MySheet( pos, - completer: closeSheet, + completer: closeOverlay, ), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -843,23 +877,25 @@ import 'package:a/a.dart' as _i3; import 'package:a/b.dart' as _i4; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, dynamic)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, required _i3.Foo<_i4.Baz> pos, }) => showBottomSheet<(bool?, dynamic), _i3.MySheet>( _i3.MySheet( pos, - completer: closeSheet, + completer: closeOverlay, ), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -890,23 +926,25 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, dynamic)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, required void Function() pos, }) => showBottomSheet<(bool?, dynamic), _i3.MySheet>( _i3.MySheet( pos, - completer: closeSheet, + completer: closeOverlay, ), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -946,23 +984,25 @@ import 'package:a/a.dart' as _i3; import 'package:a/b.dart' as _i4; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, dynamic)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, required _i3.Foo Function(_i3.Bar<_i4.Baz>) pos, }) => showBottomSheet<(bool?, dynamic), _i3.MySheet>( _i3.MySheet( pos, - completer: closeSheet, + completer: closeOverlay, ), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -1002,12 +1042,13 @@ import 'package:a/a.dart' as _i3; import 'package:a/b.dart' as _i4; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, dynamic)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, required _i3.Foo Function( _i3.Bar<_i4.Baz>, { required _i3.Foo f, @@ -1017,12 +1058,13 @@ extension BottomSheets on _i1.BottomSheetService { showBottomSheet<(bool?, dynamic), _i3.MySheet>( _i3.MySheet( pos, - completer: closeSheet, + completer: closeOverlay, ), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -1062,12 +1104,13 @@ import 'package:a/a.dart' as _i3; import 'package:a/b.dart' as _i4; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, dynamic)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, required _i3.Foo Function( _i3.Bar<_i4.Baz>, [ _i3.Foo?, @@ -1076,12 +1119,13 @@ extension BottomSheets on _i1.BottomSheetService { showBottomSheet<(bool?, dynamic), _i3.MySheet>( _i3.MySheet( pos, - completer: closeSheet, + completer: closeOverlay, ), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -1119,23 +1163,25 @@ import 'package:a/a.dart' as _i4; import 'package:a/b.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, dynamic)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, required _i3.MyCallback pos, }) => showBottomSheet<(bool?, dynamic), _i4.MySheet>( _i4.MySheet( pos, - completer: closeSheet, + completer: closeOverlay, ), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -1167,19 +1213,21 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, (int, int)?)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, }) => showBottomSheet<(bool?, (int, int)?), _i3.MySheet>( - _i3.MySheet(completer: closeSheet), + _i3.MySheet(completer: closeOverlay), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -1209,19 +1257,21 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, ({int a})?)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, }) => showBottomSheet<(bool?, ({int a})?), _i3.MySheet>( - _i3.MySheet(completer: closeSheet), + _i3.MySheet(completer: closeOverlay), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -1251,19 +1301,21 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, void Function()?)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, }) => showBottomSheet<(bool?, void Function()?), _i3.MySheet>( - _i3.MySheet(completer: closeSheet), + _i3.MySheet(completer: closeOverlay), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -1284,8 +1336,9 @@ extension BottomSheets on _i1.BottomSheetService { @BottomSheetConfig( defaultBarrierColor: 0x34ff0000, defaultFullscreen: true, - defaultIgnoreSafeArea: false, + defaultUseSafeArea: false, defaultDraggable: false, + defaultShowDragHandle: true, ) class MySheet extends FluorFlowSimpleBottomSheet { const MySheet({super.key, required this.completer}); @@ -1302,19 +1355,21 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, dynamic)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x34ff0000), bool fullscreen = true, - bool ignoreSafeArea = false, + bool useSafeArea = false, bool draggable = false, + bool showDragHandle = true, }) => showBottomSheet<(bool?, dynamic), _i3.MySheet>( - _i3.MySheet(completer: closeSheet), + _i3.MySheet(completer: closeOverlay), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' @@ -1348,19 +1403,21 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension BottomSheets on _i1.BottomSheetService { +extension BottomSheets on _i1.NavigationService { Future<(bool?, dynamic)> showMySheet({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool fullscreen = false, - bool ignoreSafeArea = true, + bool useSafeArea = false, bool draggable = true, + bool showDragHandle = false, }) => showBottomSheet<(bool?, dynamic), _i3.MySheet>( - _i3.MySheet(completer: closeSheet), + _i3.MySheet(completer: closeOverlay), barrierColor: barrierColor, fullscreen: fullscreen, draggable: draggable, - ignoreSafeArea: ignoreSafeArea, + showDragHandle: showDragHandle, + useSafeArea: useSafeArea, ).then((r) => (r?.$1, r?.$2)); } ''' diff --git a/packages/fluorflow_generator/test/builder/dialog_builder_test.dart b/packages/fluorflow_generator/test/builder/dialog_builder_test.dart index f6d3bbd..fb259f1 100644 --- a/packages/fluorflow_generator/test/builder/dialog_builder_test.dart +++ b/packages/fluorflow_generator/test/builder/dialog_builder_test.dart @@ -44,7 +44,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -58,7 +58,7 @@ extension Dialogs on _i1.DialogService { __, ___, ) => - _i3.MyDialog(completer: closeDialog)), + _i3.MyDialog(completer: closeOverlay)), ).then((r) => (r?.$1, r?.$2)); } ''' @@ -88,7 +88,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, void)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -102,7 +102,7 @@ extension Dialogs on _i1.DialogService { __, ___, ) => - _i3.MyDialog(completer: closeDialog)), + _i3.MyDialog(completer: closeOverlay)), ).then((r) => (r?.$1, null)); } ''' @@ -132,7 +132,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, String?)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -146,7 +146,7 @@ extension Dialogs on _i1.DialogService { __, ___, ) => - _i3.MyDialog(completer: closeDialog)), + _i3.MyDialog(completer: closeOverlay)), ).then((r) => (r?.$1, r?.$2)); } ''' @@ -182,7 +182,7 @@ import 'package:a/a.dart' as _i4; import 'package:a/b.dart' as _i2; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, _i2.DialogResultType?)> showMyDialog({ _i3.Color barrierColor = const _i3.Color(0x80000000), bool barrierDismissible = false, @@ -196,7 +196,7 @@ extension Dialogs on _i1.DialogService { __, ___, ) => - _i4.MyDialog(completer: closeDialog)), + _i4.MyDialog(completer: closeOverlay)), ).then((r) => (r?.$1, r?.$2)); } ''' @@ -228,7 +228,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -242,7 +242,7 @@ extension Dialogs on _i1.DialogService { __, ___, ) => - _i3.MyDialog(completer: closeDialog)), + _i3.MyDialog(completer: closeOverlay)), ).then((r) => (r?.$1, r?.$2)); } ''' @@ -272,7 +272,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, void)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -286,7 +286,7 @@ extension Dialogs on _i1.DialogService { __, ___, ) => - _i3.MyDialog(completer: closeDialog)), + _i3.MyDialog(completer: closeOverlay)), ).then((r) => (r?.$1, null)); } ''' @@ -316,7 +316,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, String?)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -330,7 +330,7 @@ extension Dialogs on _i1.DialogService { __, ___, ) => - _i3.MyDialog(completer: closeDialog)), + _i3.MyDialog(completer: closeOverlay)), ).then((r) => (r?.$1, r?.$2)); } ''' @@ -366,7 +366,7 @@ import 'package:a/a.dart' as _i4; import 'package:a/b.dart' as _i2; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, _i2.DialogResultType?)> showMyDialog({ _i3.Color barrierColor = const _i3.Color(0x80000000), bool barrierDismissible = false, @@ -380,7 +380,7 @@ extension Dialogs on _i1.DialogService { __, ___, ) => - _i4.MyDialog(completer: closeDialog)), + _i4.MyDialog(completer: closeOverlay)), ).then((r) => (r?.$1, r?.$2)); } ''' @@ -413,7 +413,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -430,7 +430,7 @@ extension Dialogs on _i1.DialogService { ) => _i3.MyDialog( pos, - completer: closeDialog, + completer: closeOverlay, )), ).then((r) => (r?.$1, r?.$2)); } @@ -462,7 +462,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -479,7 +479,7 @@ extension Dialogs on _i1.DialogService { ) => _i3.MyDialog( pos, - completer: closeDialog, + completer: closeOverlay, )), ).then((r) => (r?.$1, r?.$2)); } @@ -511,7 +511,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -527,7 +527,7 @@ extension Dialogs on _i1.DialogService { ___, ) => _i3.MyDialog( - completer: closeDialog, + completer: closeOverlay, pos: pos, )), ).then((r) => (r?.$1, r?.$2)); @@ -560,7 +560,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -576,7 +576,7 @@ extension Dialogs on _i1.DialogService { ___, ) => _i3.MyDialog( - completer: closeDialog, + completer: closeOverlay, pos: pos, )), ).then((r) => (r?.$1, r?.$2)); @@ -609,7 +609,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -625,7 +625,7 @@ extension Dialogs on _i1.DialogService { ___, ) => _i3.MyDialog( - completer: closeDialog, + completer: closeOverlay, pos: pos, )), ).then((r) => (r?.$1, r?.$2)); @@ -664,7 +664,7 @@ import 'package:a/a.dart' as _i4; import 'package:a/b.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -680,7 +680,7 @@ extension Dialogs on _i1.DialogService { ___, ) => _i4.MyDialog( - completer: closeDialog, + completer: closeOverlay, pos: pos, )), ).then((r) => (r?.$1, r?.$2)); @@ -715,7 +715,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -732,7 +732,7 @@ extension Dialogs on _i1.DialogService { ) => _i3.MyDialog( pos, - completer: closeDialog, + completer: closeOverlay, )), ).then((r) => (r?.$1, r?.$2)); } @@ -766,7 +766,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -783,7 +783,7 @@ extension Dialogs on _i1.DialogService { ) => _i3.MyDialog( pos, - completer: closeDialog, + completer: closeOverlay, )), ).then((r) => (r?.$1, r?.$2)); } @@ -823,7 +823,7 @@ import 'package:a/a.dart' as _i3; import 'package:a/b.dart' as _i4; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -840,7 +840,7 @@ extension Dialogs on _i1.DialogService { ) => _i3.MyDialog( pos, - completer: closeDialog, + completer: closeOverlay, )), ).then((r) => (r?.$1, r?.$2)); } @@ -879,7 +879,7 @@ import 'package:a/a.dart' as _i3; import 'package:a/b.dart' as _i4; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -896,7 +896,7 @@ extension Dialogs on _i1.DialogService { ) => _i3.MyDialog( pos, - completer: closeDialog, + completer: closeOverlay, )), ).then((r) => (r?.$1, r?.$2)); } @@ -928,7 +928,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -945,7 +945,7 @@ extension Dialogs on _i1.DialogService { ) => _i3.MyDialog( pos, - completer: closeDialog, + completer: closeOverlay, )), ).then((r) => (r?.$1, r?.$2)); } @@ -986,7 +986,7 @@ import 'package:a/a.dart' as _i3; import 'package:a/b.dart' as _i4; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -1003,7 +1003,7 @@ extension Dialogs on _i1.DialogService { ) => _i3.MyDialog( pos, - completer: closeDialog, + completer: closeOverlay, )), ).then((r) => (r?.$1, r?.$2)); } @@ -1044,7 +1044,7 @@ import 'package:a/a.dart' as _i3; import 'package:a/b.dart' as _i4; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -1065,7 +1065,7 @@ extension Dialogs on _i1.DialogService { ) => _i3.MyDialog( pos, - completer: closeDialog, + completer: closeOverlay, )), ).then((r) => (r?.$1, r?.$2)); } @@ -1106,7 +1106,7 @@ import 'package:a/a.dart' as _i3; import 'package:a/b.dart' as _i4; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -1126,7 +1126,7 @@ extension Dialogs on _i1.DialogService { ) => _i3.MyDialog( pos, - completer: closeDialog, + completer: closeOverlay, )), ).then((r) => (r?.$1, r?.$2)); } @@ -1165,7 +1165,7 @@ import 'package:a/a.dart' as _i4; import 'package:a/b.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -1182,7 +1182,7 @@ extension Dialogs on _i1.DialogService { ) => _i4.MyDialog( pos, - completer: closeDialog, + completer: closeOverlay, )), ).then((r) => (r?.$1, r?.$2)); } @@ -1215,7 +1215,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, (int, int)?)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -1229,7 +1229,7 @@ extension Dialogs on _i1.DialogService { __, ___, ) => - _i3.MyDialog(completer: closeDialog)), + _i3.MyDialog(completer: closeOverlay)), ).then((r) => (r?.$1, r?.$2)); } ''' @@ -1259,7 +1259,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, ({int a})?)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -1273,7 +1273,7 @@ extension Dialogs on _i1.DialogService { __, ___, ) => - _i3.MyDialog(completer: closeDialog)), + _i3.MyDialog(completer: closeOverlay)), ).then((r) => (r?.$1, r?.$2)); } ''' @@ -1303,7 +1303,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, void Function()?)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -1317,7 +1317,7 @@ extension Dialogs on _i1.DialogService { __, ___, ) => - _i3.MyDialog(completer: closeDialog)), + _i3.MyDialog(completer: closeOverlay)), ).then((r) => (r?.$1, r?.$2)); } ''' @@ -1354,7 +1354,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x34ff0000), bool barrierDismissible = true, @@ -1368,7 +1368,7 @@ extension Dialogs on _i1.DialogService { __, ___, ) => - _i3.MyDialog(completer: closeDialog)), + _i3.MyDialog(completer: closeOverlay)), ).then((r) => (r?.$1, r?.$2)); } ''' @@ -1410,7 +1410,7 @@ import 'package:a/a.dart' as _i4; import 'package:a/b.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -1424,7 +1424,7 @@ extension Dialogs on _i1.DialogService { __, ___, ) => - _i4.MyDialog(completer: closeDialog)), + _i4.MyDialog(completer: closeOverlay)), ).then((r) => (r?.$1, r?.$2)); } ''' @@ -1462,7 +1462,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -1476,7 +1476,7 @@ extension Dialogs on _i1.DialogService { __, ___, ) => - _i3.MyDialog(completer: closeDialog)), + _i3.MyDialog(completer: closeOverlay)), ).then((r) => (r?.\$1, r?.\$2)); } ''', @@ -1511,7 +1511,7 @@ import 'dart:ui' as _i2; import 'package:a/a.dart' as _i3; import 'package:fluorflow/fluorflow.dart' as _i1; -extension Dialogs on _i1.DialogService { +extension Dialogs on _i1.NavigationService { Future<(bool?, dynamic)> showMyDialog({ _i2.Color barrierColor = const _i2.Color(0x80000000), bool barrierDismissible = false, @@ -1525,7 +1525,7 @@ extension Dialogs on _i1.DialogService { __, ___, ) => - _i3.MyDialog(completer: closeDialog)), + _i3.MyDialog(completer: closeOverlay)), ).then((r) => (r?.$1, r?.$2)); } ''' diff --git a/packages/fluorflow_generator/test/builder/locator_builder_test.dart b/packages/fluorflow_generator/test/builder/locator_builder_test.dart index 8cc57d1..fc4bbf5 100644 --- a/packages/fluorflow_generator/test/builder/locator_builder_test.dart +++ b/packages/fluorflow_generator/test/builder/locator_builder_test.dart @@ -26,8 +26,6 @@ import 'package:fluorflow/fluorflow.dart' as _i1; Future setupLocator() async { _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } ''' @@ -65,8 +63,6 @@ Future setupLocator() async { _i1.locator.registerSingleton(_i2.ServiceA()); _i1.locator.registerSingleton(_i3.ServiceB()); _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } ''' @@ -109,8 +105,6 @@ Future setupLocator() async { ); _i1.locator.registerSingleton(_i3.ServiceB()); _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } ''' @@ -142,8 +136,6 @@ import 'package:fluorflow/fluorflow.dart' as _i1; Future setupLocator() async { _i1.locator.registerSingleton(_i2.factory()); _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } ''' @@ -182,8 +174,6 @@ Future setupLocator() async { dependsOn: [_i2.SvcA], ); _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } ''' @@ -223,8 +213,6 @@ Future setupLocator() async { _i1.locator.registerLazySingleton(() => _i2.ServiceA()); _i1.locator.registerLazySingleton(() => _i3.ServiceB()); _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } ''' @@ -256,8 +244,6 @@ import 'package:fluorflow/fluorflow.dart' as _i1; Future setupLocator() async { _i1.locator.registerLazySingleton(_i2.factory); _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } ''' @@ -303,8 +289,6 @@ Future setupLocator() async { _i1.locator.registerSingletonAsync(_i2.AsyncSingletonServiceA.create); _i1.locator.registerSingletonAsync(_i3.createService); _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } ''' @@ -375,8 +359,6 @@ Future setupLocator() async { ); _i1.locator.registerSingletonAsync(_i3.createService); _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } ''' @@ -408,8 +390,6 @@ import 'package:fluorflow/fluorflow.dart' as _i1; Future setupLocator() async { _i1.locator.registerSingletonAsync(_i2.factory); _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } ''' @@ -448,8 +428,6 @@ Future setupLocator() async { dependsOn: [_i2.SvcA], ); _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } ''' @@ -483,8 +461,6 @@ import 'package:fluorflow/fluorflow.dart' as _i1; Future setupLocator() async { _i1.locator.registerFactory(() => _i2.factory()); _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } ''' @@ -518,8 +494,6 @@ import 'package:fluorflow/fluorflow.dart' as _i1; Future setupLocator() async { _i1.locator.registerFactory(() => _i2.factory()); _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } ''' @@ -558,8 +532,6 @@ Future setupLocator() async { ) => _i2.factory(p1)); _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } @@ -608,8 +580,6 @@ Future setupLocator() async { ) => _i3.factory(p1)); _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } @@ -658,8 +628,6 @@ Future setupLocator() async { p2, )); _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } @@ -721,8 +689,6 @@ Future setupLocator() async { p2, )); _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } @@ -808,8 +774,6 @@ import 'package:fluorflow/fluorflow.dart' as _i1; Future setupLocator() async { _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } ''' @@ -847,8 +811,6 @@ import 'package:fluorflow/fluorflow.dart' as _i1; Future setupLocator() async { _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } ''' @@ -879,8 +841,6 @@ import 'package:fluorflow/fluorflow.dart' as _i1; Future setupLocator() async { _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } ''' @@ -910,8 +870,6 @@ import 'package:fluorflow/fluorflow.dart' as _i2; Future setupLocator() async { _i1.customFunc(); _i2.locator.registerLazySingleton(() => _i2.NavigationService()); - _i2.locator.registerLazySingleton(() => _i2.DialogService()); - _i2.locator.registerLazySingleton(() => _i2.BottomSheetService()); await _i2.locator.allReady(); } ''' @@ -962,8 +920,6 @@ import 'package:fluorflow/fluorflow.dart' as _i1; Future setupLocator() async { _i1.locator.registerSingleton(_i2.ServiceA()); _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); } ''' }, @@ -994,8 +950,6 @@ import 'package:fluorflow/fluorflow.dart' as _i1; Future setupLocator() async { _i1.locator.registerSingleton(_i2.ServiceA()); _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); await _i1.locator.allReady(); } ''' @@ -1026,72 +980,6 @@ import 'package:fluorflow/fluorflow.dart' as _i1; Future setupLocator() async { _i1.locator.registerSingleton(_i2.ServiceA()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); - await _i1.locator.allReady(); -} -''' - }, - reader: await PackageAssetReader.currentIsolate())); - - test( - 'should not register DialogService when disabled.', - () async => await testBuilder( - LocatorBuilder(BuilderOptions({ - 'register_services': {'dialog': false}, - })), - { - 'a|lib/a.dart': ''' - import 'package:fluorflow/annotations.dart'; - - @Singleton() - class ServiceA {} - ''' - }, - outputs: { - 'a|lib/app.locator.dart': ''' -// ignore_for_file: type=lint - -// ignore_for_file: no_leading_underscores_for_library_prefixes -import 'package:a/a.dart' as _i2; -import 'package:fluorflow/fluorflow.dart' as _i1; - -Future setupLocator() async { - _i1.locator.registerSingleton(_i2.ServiceA()); - _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.BottomSheetService()); - await _i1.locator.allReady(); -} -''' - }, - reader: await PackageAssetReader.currentIsolate())); - - test( - 'should not register BottomSheetService when disabled.', - () async => await testBuilder( - LocatorBuilder(BuilderOptions({ - 'register_services': {'bottomSheet': false}, - })), - { - 'a|lib/a.dart': ''' - import 'package:fluorflow/annotations.dart'; - - @Singleton() - class ServiceA {} - ''' - }, - outputs: { - 'a|lib/app.locator.dart': ''' -// ignore_for_file: type=lint - -// ignore_for_file: no_leading_underscores_for_library_prefixes -import 'package:a/a.dart' as _i2; -import 'package:fluorflow/fluorflow.dart' as _i1; - -Future setupLocator() async { - _i1.locator.registerSingleton(_i2.ServiceA()); - _i1.locator.registerLazySingleton(() => _i1.NavigationService()); - _i1.locator.registerLazySingleton(() => _i1.DialogService()); await _i1.locator.allReady(); } ''' diff --git a/packages/fluorflow_generator/test/builder/router_builder_test.dart b/packages/fluorflow_generator/test/builder/router_builder_test.dart index 7d46cd3..2492e3a 100644 --- a/packages/fluorflow_generator/test/builder/router_builder_test.dart +++ b/packages/fluorflow_generator/test/builder/router_builder_test.dart @@ -65,14 +65,8 @@ final _pages = { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({bool preventDuplicates = true}) => navigateTo( - AppRoute.view.path, - preventDuplicates: preventDuplicates, - ); - void replaceWithView({bool preventDuplicates = true}) => replaceWith( - AppRoute.view.path, - preventDuplicates: preventDuplicates, - ); + Future? navigateToView() => navigateTo(AppRoute.view.path); + void replaceWithView() => replaceWith(AppRoute.view.path); void rootToView() => rootTo(AppRoute.view.path); } ''', @@ -123,14 +117,8 @@ final _pages = { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({bool preventDuplicates = true}) => navigateTo( - AppRoute.view.path, - preventDuplicates: preventDuplicates, - ); - void replaceWithView({bool preventDuplicates = true}) => replaceWith( - AppRoute.view.path, - preventDuplicates: preventDuplicates, - ); + Future? navigateToView() => navigateTo(AppRoute.view.path); + void replaceWithView() => replaceWith(AppRoute.view.path); void rootToView() => rootTo(AppRoute.view.path); } ''', @@ -181,10 +169,7 @@ final _pages = { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - void replaceWithView({bool preventDuplicates = true}) => replaceWith( - AppRoute.view.path, - preventDuplicates: preventDuplicates, - ); + void replaceWithView() => replaceWith(AppRoute.view.path); void rootToView() => rootTo(AppRoute.view.path); } ''', @@ -235,10 +220,7 @@ final _pages = { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({bool preventDuplicates = true}) => navigateTo( - AppRoute.view.path, - preventDuplicates: preventDuplicates, - ); + Future? navigateToView() => navigateTo(AppRoute.view.path); void rootToView() => rootTo(AppRoute.view.path); } ''', @@ -289,14 +271,8 @@ final _pages = { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({bool preventDuplicates = true}) => navigateTo( - AppRoute.view.path, - preventDuplicates: preventDuplicates, - ); - void replaceWithView({bool preventDuplicates = true}) => replaceWith( - AppRoute.view.path, - preventDuplicates: preventDuplicates, - ); + Future? navigateToView() => navigateTo(AppRoute.view.path); + void replaceWithView() => replaceWith(AppRoute.view.path); } ''', }, @@ -353,14 +329,8 @@ final _pages = { final onGenerateRoute = _i4.generateRouteFactory(_pages); extension RouteNavigation on _i4.NavigationService { - Future? navigateToView({bool preventDuplicates = true}) => navigateTo( - AppRoute.view.path, - preventDuplicates: preventDuplicates, - ); - void replaceWithView({bool preventDuplicates = true}) => replaceWith( - AppRoute.view.path, - preventDuplicates: preventDuplicates, - ); + Future? navigateToView() => navigateTo(AppRoute.view.path); + void replaceWithView() => replaceWith(AppRoute.view.path); void rootToView() => rootTo(AppRoute.view.path); } ''', @@ -414,14 +384,8 @@ final _pages = { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({bool preventDuplicates = true}) => navigateTo( - AppRoute.view.path, - preventDuplicates: preventDuplicates, - ); - void replaceWithView({bool preventDuplicates = true}) => replaceWith( - AppRoute.view.path, - preventDuplicates: preventDuplicates, - ); + Future? navigateToView() => navigateTo(AppRoute.view.path); + void replaceWithView() => replaceWith(AppRoute.view.path); void rootToView() => rootTo(AppRoute.view.path); } ''', @@ -475,14 +439,8 @@ final _pages = { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({bool preventDuplicates = true}) => navigateTo( - AppRoute.view.path, - preventDuplicates: preventDuplicates, - ); - void replaceWithView({bool preventDuplicates = true}) => replaceWith( - AppRoute.view.path, - preventDuplicates: preventDuplicates, - ); + Future? navigateToView() => navigateTo(AppRoute.view.path); + void replaceWithView() => replaceWith(AppRoute.view.path); void rootToView() => rootTo(AppRoute.view.path); } ''', @@ -535,14 +493,8 @@ final _pages = { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({bool preventDuplicates = true}) => navigateTo( - AppRoute.view.path, - preventDuplicates: preventDuplicates, - ); - void replaceWithView({bool preventDuplicates = true}) => replaceWith( - AppRoute.view.path, - preventDuplicates: preventDuplicates, - ); + Future? navigateToView() => navigateTo(AppRoute.view.path); + void replaceWithView() => replaceWith(AppRoute.view.path); void rootToView() => rootTo(AppRoute.view.path); } ''', @@ -605,22 +557,12 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - required String arg, - bool preventDuplicates = true, - }) => - navigateTo( + Future? navigateToView({required String arg}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - required String arg, - bool preventDuplicates = true, - }) => - replaceWith( + void replaceWithView({required String arg}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView({required String arg}) => rootTo( @@ -688,22 +630,12 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - required String? arg, - bool preventDuplicates = true, - }) => - navigateTo( + Future? navigateToView({required String? arg}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - required String? arg, - bool preventDuplicates = true, - }) => - replaceWith( + void replaceWithView({required String? arg}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView({required String? arg}) => rootTo( @@ -771,22 +703,12 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - String arg = 'default', - bool preventDuplicates = true, - }) => - navigateTo( + Future? navigateToView({String arg = 'default'}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - String arg = 'default', - bool preventDuplicates = true, - }) => - replaceWith( + void replaceWithView({String arg = 'default'}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView({String arg = 'default'}) => rootTo( @@ -854,22 +776,12 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - required String arg, - bool preventDuplicates = true, - }) => - navigateTo( + Future? navigateToView({required String arg}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - required String arg, - bool preventDuplicates = true, - }) => - replaceWith( + void replaceWithView({required String arg}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView({required String arg}) => rootTo( @@ -937,22 +849,12 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - String? arg, - bool preventDuplicates = true, - }) => - navigateTo( + Future? navigateToView({String? arg}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - String? arg, - bool preventDuplicates = true, - }) => - replaceWith( + void replaceWithView({String? arg}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView({String? arg}) => rootTo( @@ -1020,22 +922,12 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - String arg = 'default', - bool preventDuplicates = true, - }) => - navigateTo( + Future? navigateToView({String arg = 'default'}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - String arg = 'default', - bool preventDuplicates = true, - }) => - replaceWith( + void replaceWithView({String arg = 'default'}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView({String arg = 'default'}) => rootTo( @@ -1109,22 +1001,12 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - required _i4.Arg arg, - bool preventDuplicates = true, - }) => - navigateTo( + Future? navigateToView({required _i4.Arg arg}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - required _i4.Arg arg, - bool preventDuplicates = true, - }) => - replaceWith( + void replaceWithView({required _i4.Arg arg}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView({required _i4.Arg arg}) => rootTo( @@ -1184,14 +1066,8 @@ final _pages = { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({bool preventDuplicates = true}) => navigateTo( - AppRoute.view.path, - preventDuplicates: preventDuplicates, - ); - void replaceWithView({bool preventDuplicates = true}) => replaceWith( - AppRoute.view.path, - preventDuplicates: preventDuplicates, - ); + Future? navigateToView() => navigateTo(AppRoute.view.path); + void replaceWithView() => replaceWith(AppRoute.view.path); void rootToView() => rootTo(AppRoute.view.path); } ''', @@ -1256,22 +1132,12 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - required List arg, - bool preventDuplicates = true, - }) => - navigateTo( + Future? navigateToView({required List arg}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - required List arg, - bool preventDuplicates = true, - }) => - replaceWith( + void replaceWithView({required List arg}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView({required List arg}) => rootTo( @@ -1341,22 +1207,12 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - required List<_i3.Foobar> arg, - bool preventDuplicates = true, - }) => - navigateTo( + Future? navigateToView({required List<_i3.Foobar> arg}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - required List<_i3.Foobar> arg, - bool preventDuplicates = true, - }) => - replaceWith( + void replaceWithView({required List<_i3.Foobar> arg}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView({required List<_i3.Foobar> arg}) => rootTo( @@ -1426,22 +1282,16 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - required (_i3.Foobar, int, {_i3.Foobar f, String name}) arg, - bool preventDuplicates = true, - }) => + Future? navigateToView( + {required (_i3.Foobar, int, {_i3.Foobar f, String name}) arg}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - required (_i3.Foobar, int, {_i3.Foobar f, String name}) arg, - bool preventDuplicates = true, - }) => + void replaceWithView( + {required (_i3.Foobar, int, {_i3.Foobar f, String name}) arg}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView( @@ -1513,22 +1363,12 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - (_i3.Foobar, int)? arg, - bool preventDuplicates = true, - }) => - navigateTo( + Future? navigateToView({(_i3.Foobar, int)? arg}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - (_i3.Foobar, int)? arg, - bool preventDuplicates = true, - }) => - replaceWith( + void replaceWithView({(_i3.Foobar, int)? arg}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView({(_i3.Foobar, int)? arg}) => rootTo( @@ -1605,22 +1445,15 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - required _i3.Foo<_i3.Bar<_i4.Baz, int>> arg, - bool preventDuplicates = true, - }) => + Future? navigateToView( + {required _i3.Foo<_i3.Bar<_i4.Baz, int>> arg}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - required _i3.Foo<_i3.Bar<_i4.Baz, int>> arg, - bool preventDuplicates = true, - }) => + void replaceWithView({required _i3.Foo<_i3.Bar<_i4.Baz, int>> arg}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView({required _i3.Foo<_i3.Bar<_i4.Baz, int>> arg}) => rootTo( @@ -1696,22 +1529,12 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - required _i3.Foo<_i4.Baz> arg, - bool preventDuplicates = true, - }) => - navigateTo( + Future? navigateToView({required _i3.Foo<_i4.Baz> arg}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - required _i3.Foo<_i4.Baz> arg, - bool preventDuplicates = true, - }) => - replaceWith( + void replaceWithView({required _i3.Foo<_i4.Baz> arg}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView({required _i3.Foo<_i4.Baz> arg}) => rootTo( @@ -1779,22 +1602,12 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - required void Function() arg, - bool preventDuplicates = true, - }) => - navigateTo( + Future? navigateToView({required void Function() arg}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - required void Function() arg, - bool preventDuplicates = true, - }) => - replaceWith( + void replaceWithView({required void Function() arg}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView({required void Function() arg}) => rootTo( @@ -1872,22 +1685,15 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - required _i3.Foo Function(_i3.Bar<_i4.Baz>) arg, - bool preventDuplicates = true, - }) => + Future? navigateToView( + {required _i3.Foo Function(_i3.Bar<_i4.Baz>) arg}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - required _i3.Foo Function(_i3.Bar<_i4.Baz>) arg, - bool preventDuplicates = true, - }) => + void replaceWithView({required _i3.Foo Function(_i3.Bar<_i4.Baz>) arg}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView({required _i3.Foo Function(_i3.Bar<_i4.Baz>) arg}) => rootTo( @@ -1969,30 +1775,24 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - required _i3.Foo Function( - _i3.Bar<_i4.Baz>, { - required _i3.Foo f, - _i4.Baz? b, - }) arg, - bool preventDuplicates = true, - }) => + Future? navigateToView( + {required _i3.Foo Function( + _i3.Bar<_i4.Baz>, { + required _i3.Foo f, + _i4.Baz? b, + }) arg}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - required _i3.Foo Function( - _i3.Bar<_i4.Baz>, { - required _i3.Foo f, - _i4.Baz? b, - }) arg, - bool preventDuplicates = true, - }) => + void replaceWithView( + {required _i3.Foo Function( + _i3.Bar<_i4.Baz>, { + required _i3.Foo f, + _i4.Baz? b, + }) arg}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView( @@ -2079,28 +1879,22 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - required _i3.Foo Function( - _i3.Bar<_i4.Baz>, [ - _i3.Foo?, - ]) arg, - bool preventDuplicates = true, - }) => + Future? navigateToView( + {required _i3.Foo Function( + _i3.Bar<_i4.Baz>, [ + _i3.Foo?, + ]) arg}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - required _i3.Foo Function( - _i3.Bar<_i4.Baz>, [ - _i3.Foo?, - ]) arg, - bool preventDuplicates = true, - }) => + void replaceWithView( + {required _i3.Foo Function( + _i3.Bar<_i4.Baz>, [ + _i3.Foo?, + ]) arg}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView( @@ -2181,22 +1975,12 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - required _i4.MyCallback arg, - bool preventDuplicates = true, - }) => - navigateTo( + Future? navigateToView({required _i4.MyCallback arg}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - required _i4.MyCallback arg, - bool preventDuplicates = true, - }) => - replaceWith( + void replaceWithView({required _i4.MyCallback arg}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView({required _i4.MyCallback arg}) => rootTo( @@ -2275,22 +2059,12 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - required _i4.MyTuple arg, - bool preventDuplicates = true, - }) => - navigateTo( + Future? navigateToView({required _i4.MyTuple arg}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - required _i4.MyTuple arg, - bool preventDuplicates = true, - }) => - replaceWith( + void replaceWithView({required _i4.MyTuple arg}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView({required _i4.MyTuple arg}) => rootTo( @@ -2369,22 +2143,12 @@ class ViewArguments { final onGenerateRoute = _i2.generateRouteFactory(_pages); extension RouteNavigation on _i2.NavigationService { - Future? navigateToView({ - required _i4.MyRecord arg, - bool preventDuplicates = true, - }) => - navigateTo( + Future? navigateToView({required _i4.MyRecord arg}) => navigateTo( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); - void replaceWithView({ - required _i4.MyRecord arg, - bool preventDuplicates = true, - }) => - replaceWith( + void replaceWithView({required _i4.MyRecord arg}) => replaceWith( AppRoute.view.path, - preventDuplicates: preventDuplicates, arguments: ViewArguments(arg: arg), ); void rootToView({required _i4.MyRecord arg}) => rootTo( diff --git a/packages/fluorflow_generator/test/builder/test_locator_builder_test.dart b/packages/fluorflow_generator/test/builder/test_locator_builder_test.dart index b68dcd9..4dab79f 100644 --- a/packages/fluorflow_generator/test/builder/test_locator_builder_test.dart +++ b/packages/fluorflow_generator/test/builder/test_locator_builder_test.dart @@ -64,36 +64,12 @@ _i1.MockNavigationService getMockNavigationService() { return service; } -_i1.MockDialogService getMockDialogService() { - if (_i2.locator.isRegistered<_i2.DialogService>()) { - _i2.locator.unregister<_i2.DialogService>(); - } - final service = _i1.MockDialogService(); - _i2.locator.registerSingleton<_i2.DialogService>(service); - return service; -} - -_i1.MockBottomSheetService getMockBottomSheetService() { - if (_i2.locator.isRegistered<_i2.BottomSheetService>()) { - _i2.locator.unregister<_i2.BottomSheetService>(); - } - final service = _i1.MockBottomSheetService(); - _i2.locator.registerSingleton<_i2.BottomSheetService>(service); - return service; -} - @_i3.GenerateNiceMocks([ _i3.MockSpec<_i2.NavigationService>( - onMissingStub: _i3.OnMissingStub.returnDefault), - _i3.MockSpec<_i2.DialogService>( - onMissingStub: _i3.OnMissingStub.returnDefault), - _i3.MockSpec<_i2.BottomSheetService>( - onMissingStub: _i3.OnMissingStub.returnDefault), + onMissingStub: _i3.OnMissingStub.returnDefault) ]) void setupTestLocator() { getMockNavigationService(); - getMockDialogService(); - getMockBottomSheetService(); } void tearDownLocator() => _i2.locator.reset(); @@ -506,36 +482,12 @@ _i1.MockNavigationService getMockNavigationService() { return service; } -_i1.MockDialogService getMockDialogService() { - if (_i2.locator.isRegistered<_i2.DialogService>()) { - _i2.locator.unregister<_i2.DialogService>(); - } - final service = _i1.MockDialogService(); - _i2.locator.registerSingleton<_i2.DialogService>(service); - return service; -} - -_i1.MockBottomSheetService getMockBottomSheetService() { - if (_i2.locator.isRegistered<_i2.BottomSheetService>()) { - _i2.locator.unregister<_i2.BottomSheetService>(); - } - final service = _i1.MockBottomSheetService(); - _i2.locator.registerSingleton<_i2.BottomSheetService>(service); - return service; -} - @_i3.GenerateNiceMocks([ _i3.MockSpec<_i2.NavigationService>( - onMissingStub: _i3.OnMissingStub.returnDefault), - _i3.MockSpec<_i2.DialogService>( - onMissingStub: _i3.OnMissingStub.returnDefault), - _i3.MockSpec<_i2.BottomSheetService>( - onMissingStub: _i3.OnMissingStub.returnDefault), + onMissingStub: _i3.OnMissingStub.returnDefault) ]) void setupTestLocator() { getMockNavigationService(); - getMockDialogService(); - getMockBottomSheetService(); } void tearDownLocator() => _i2.locator.reset(); @@ -560,149 +512,10 @@ void tearDownLocator() => _i2.locator.reset(); // ignore_for_file: no_leading_underscores_for_library_prefixes import 'package:fluorflow/fluorflow.dart' as _i2; -import 'package:mockito/annotations.dart' as _i3; - -import 'test.locator.mocks.dart' as _i1; - -_i1.MockDialogService getMockDialogService() { - if (_i2.locator.isRegistered<_i2.DialogService>()) { - _i2.locator.unregister<_i2.DialogService>(); - } - final service = _i1.MockDialogService(); - _i2.locator.registerSingleton<_i2.DialogService>(service); - return service; -} - -_i1.MockBottomSheetService getMockBottomSheetService() { - if (_i2.locator.isRegistered<_i2.BottomSheetService>()) { - _i2.locator.unregister<_i2.BottomSheetService>(); - } - final service = _i1.MockBottomSheetService(); - _i2.locator.registerSingleton<_i2.BottomSheetService>(service); - return service; -} - -@_i3.GenerateNiceMocks([ - _i3.MockSpec<_i2.DialogService>( - onMissingStub: _i3.OnMissingStub.returnDefault), - _i3.MockSpec<_i2.BottomSheetService>( - onMissingStub: _i3.OnMissingStub.returnDefault), -]) -void setupTestLocator() { - getMockDialogService(); - getMockBottomSheetService(); -} - -void tearDownLocator() => _i2.locator.reset(); -''' - }, - reader: await PackageAssetReader.currentIsolate())); - - test( - 'should not mock dialog service when disabled.', - () async => await testBuilder( - TestLocatorBuilder(BuilderOptions({ - 'services': {'dialog': false}, - })), - { - 'a|lib/a.dart': ''' - class View {} - ''' - }, - outputs: { - 'a|test/test.locator.dart': ''' -// ignore_for_file: type=lint - -// ignore_for_file: no_leading_underscores_for_library_prefixes -import 'package:fluorflow/fluorflow.dart' as _i2; -import 'package:mockito/annotations.dart' as _i3; - -import 'test.locator.mocks.dart' as _i1; - -_i1.MockNavigationService getMockNavigationService() { - if (_i2.locator.isRegistered<_i2.NavigationService>()) { - _i2.locator.unregister<_i2.NavigationService>(); - } - final service = _i1.MockNavigationService(); - _i2.locator.registerSingleton<_i2.NavigationService>(service); - return service; -} - -_i1.MockBottomSheetService getMockBottomSheetService() { - if (_i2.locator.isRegistered<_i2.BottomSheetService>()) { - _i2.locator.unregister<_i2.BottomSheetService>(); - } - final service = _i1.MockBottomSheetService(); - _i2.locator.registerSingleton<_i2.BottomSheetService>(service); - return service; -} - -@_i3.GenerateNiceMocks([ - _i3.MockSpec<_i2.NavigationService>( - onMissingStub: _i3.OnMissingStub.returnDefault), - _i3.MockSpec<_i2.BottomSheetService>( - onMissingStub: _i3.OnMissingStub.returnDefault), -]) -void setupTestLocator() { - getMockNavigationService(); - getMockBottomSheetService(); -} - -void tearDownLocator() => _i2.locator.reset(); -''' - }, - reader: await PackageAssetReader.currentIsolate())); - - test( - 'should not mock buttom sheet service when disabled.', - () async => await testBuilder( - TestLocatorBuilder(BuilderOptions({ - 'services': {'bottomSheet': false}, - })), - { - 'a|lib/a.dart': ''' - class View {} - ''' - }, - outputs: { - 'a|test/test.locator.dart': ''' -// ignore_for_file: type=lint - -// ignore_for_file: no_leading_underscores_for_library_prefixes -import 'package:fluorflow/fluorflow.dart' as _i2; -import 'package:mockito/annotations.dart' as _i3; - -import 'test.locator.mocks.dart' as _i1; - -_i1.MockNavigationService getMockNavigationService() { - if (_i2.locator.isRegistered<_i2.NavigationService>()) { - _i2.locator.unregister<_i2.NavigationService>(); - } - final service = _i1.MockNavigationService(); - _i2.locator.registerSingleton<_i2.NavigationService>(service); - return service; -} - -_i1.MockDialogService getMockDialogService() { - if (_i2.locator.isRegistered<_i2.DialogService>()) { - _i2.locator.unregister<_i2.DialogService>(); - } - final service = _i1.MockDialogService(); - _i2.locator.registerSingleton<_i2.DialogService>(service); - return service; -} - -@_i3.GenerateNiceMocks([ - _i3.MockSpec<_i2.NavigationService>( - onMissingStub: _i3.OnMissingStub.returnDefault), - _i3.MockSpec<_i2.DialogService>( - onMissingStub: _i3.OnMissingStub.returnDefault), -]) -void setupTestLocator() { - getMockNavigationService(); - getMockDialogService(); -} +import 'package:mockito/annotations.dart' as _i1; +@_i1.GenerateNiceMocks([]) +void setupTestLocator() {} void tearDownLocator() => _i2.locator.reset(); ''' }, @@ -767,36 +580,12 @@ _i1.MockNavigationService getMockNavigationService() { return service; } -_i1.MockDialogService getMockDialogService() { - if (_i2.locator.isRegistered<_i2.DialogService>()) { - _i2.locator.unregister<_i2.DialogService>(); - } - final service = _i1.MockDialogService(); - _i2.locator.registerSingleton<_i2.DialogService>(service); - return service; -} - -_i1.MockBottomSheetService getMockBottomSheetService() { - if (_i2.locator.isRegistered<_i2.BottomSheetService>()) { - _i2.locator.unregister<_i2.BottomSheetService>(); - } - final service = _i1.MockBottomSheetService(); - _i2.locator.registerSingleton<_i2.BottomSheetService>(service); - return service; -} - @_i3.GenerateNiceMocks([ _i3.MockSpec<_i2.NavigationService>( - onMissingStub: _i3.OnMissingStub.returnDefault), - _i3.MockSpec<_i2.DialogService>( - onMissingStub: _i3.OnMissingStub.returnDefault), - _i3.MockSpec<_i2.BottomSheetService>( - onMissingStub: _i3.OnMissingStub.returnDefault), + onMissingStub: _i3.OnMissingStub.returnDefault) ]) void setupTestLocator() { getMockNavigationService(); - getMockDialogService(); - getMockBottomSheetService(); } void tearDownLocator() => _i2.locator.reset(); @@ -845,36 +634,12 @@ _i1.MockNavigationService getMockNavigationService() { return service; } -_i1.MockDialogService getMockDialogService() { - if (_i2.locator.isRegistered<_i2.DialogService>()) { - _i2.locator.unregister<_i2.DialogService>(); - } - final service = _i1.MockDialogService(); - _i2.locator.registerSingleton<_i2.DialogService>(service); - return service; -} - -_i1.MockBottomSheetService getMockBottomSheetService() { - if (_i2.locator.isRegistered<_i2.BottomSheetService>()) { - _i2.locator.unregister<_i2.BottomSheetService>(); - } - final service = _i1.MockBottomSheetService(); - _i2.locator.registerSingleton<_i2.BottomSheetService>(service); - return service; -} - @_i3.GenerateNiceMocks([ _i3.MockSpec<_i2.NavigationService>( - onMissingStub: _i3.OnMissingStub.returnDefault), - _i3.MockSpec<_i2.DialogService>( - onMissingStub: _i3.OnMissingStub.returnDefault), - _i3.MockSpec<_i2.BottomSheetService>( - onMissingStub: _i3.OnMissingStub.returnDefault), + onMissingStub: _i3.OnMissingStub.returnDefault) ]) void setupTestLocator() { getMockNavigationService(); - getMockDialogService(); - getMockBottomSheetService(); } void tearDownLocator() => _i2.locator.reset(); @@ -916,36 +681,12 @@ _i1.MockNavigationService getMockNavigationService() { return service; } -_i1.MockDialogService getMockDialogService() { - if (_i2.locator.isRegistered<_i2.DialogService>()) { - _i2.locator.unregister<_i2.DialogService>(); - } - final service = _i1.MockDialogService(); - _i2.locator.registerSingleton<_i2.DialogService>(service); - return service; -} - -_i1.MockBottomSheetService getMockBottomSheetService() { - if (_i2.locator.isRegistered<_i2.BottomSheetService>()) { - _i2.locator.unregister<_i2.BottomSheetService>(); - } - final service = _i1.MockBottomSheetService(); - _i2.locator.registerSingleton<_i2.BottomSheetService>(service); - return service; -} - @_i3.GenerateNiceMocks([ _i3.MockSpec<_i2.NavigationService>( - onMissingStub: _i3.OnMissingStub.returnDefault), - _i3.MockSpec<_i2.DialogService>( - onMissingStub: _i3.OnMissingStub.returnDefault), - _i3.MockSpec<_i2.BottomSheetService>( - onMissingStub: _i3.OnMissingStub.returnDefault), + onMissingStub: _i3.OnMissingStub.returnDefault) ]) void setupTestLocator() { getMockNavigationService(); - getMockDialogService(); - getMockBottomSheetService(); } void tearDownLocator() => _i2.locator.reset(); @@ -985,37 +726,13 @@ _i1.MockNavigationService getMockNavigationService() { return service; } -_i1.MockDialogService getMockDialogService() { - if (_i2.locator.isRegistered<_i2.DialogService>()) { - _i2.locator.unregister<_i2.DialogService>(); - } - final service = _i1.MockDialogService(); - _i2.locator.registerSingleton<_i2.DialogService>(service); - return service; -} - -_i1.MockBottomSheetService getMockBottomSheetService() { - if (_i2.locator.isRegistered<_i2.BottomSheetService>()) { - _i2.locator.unregister<_i2.BottomSheetService>(); - } - final service = _i1.MockBottomSheetService(); - _i2.locator.registerSingleton<_i2.BottomSheetService>(service); - return service; -} - @_i3.GenerateNiceMocks([ _i3.MockSpec<_i2.NavigationService>( - onMissingStub: _i3.OnMissingStub.returnDefault), - _i3.MockSpec<_i2.DialogService>( - onMissingStub: _i3.OnMissingStub.returnDefault), - _i3.MockSpec<_i2.BottomSheetService>( - onMissingStub: _i3.OnMissingStub.returnDefault), + onMissingStub: _i3.OnMissingStub.returnDefault) ]) void setupTestLocator() { _i4.customFunc(); getMockNavigationService(); - getMockDialogService(); - getMockBottomSheetService(); } void tearDownLocator() => _i2.locator.reset(); @@ -1055,37 +772,13 @@ _i1.MockNavigationService getMockNavigationService() { return service; } -_i1.MockDialogService getMockDialogService() { - if (_i2.locator.isRegistered<_i2.DialogService>()) { - _i2.locator.unregister<_i2.DialogService>(); - } - final service = _i1.MockDialogService(); - _i2.locator.registerSingleton<_i2.DialogService>(service); - return service; -} - -_i1.MockBottomSheetService getMockBottomSheetService() { - if (_i2.locator.isRegistered<_i2.BottomSheetService>()) { - _i2.locator.unregister<_i2.BottomSheetService>(); - } - final service = _i1.MockBottomSheetService(); - _i2.locator.registerSingleton<_i2.BottomSheetService>(service); - return service; -} - @_i3.GenerateNiceMocks([ _i3.MockSpec<_i2.NavigationService>( - onMissingStub: _i3.OnMissingStub.returnDefault), - _i3.MockSpec<_i2.DialogService>( - onMissingStub: _i3.OnMissingStub.returnDefault), - _i3.MockSpec<_i2.BottomSheetService>( - onMissingStub: _i3.OnMissingStub.returnDefault), + onMissingStub: _i3.OnMissingStub.returnDefault) ]) void setupTestLocator() { _i4.customFunc(); getMockNavigationService(); - getMockDialogService(); - getMockBottomSheetService(); } void tearDownLocator() => _i2.locator.reset();