Ahmed Fwela

Added GetRouteAwarePageBuilder

@@ -102,7 +102,13 @@ class GetPageRoute<T> extends PageRoute<T> with GetPageRouteTransitionMixin<T> { @@ -102,7 +102,13 @@ class GetPageRoute<T> extends PageRoute<T> with GetPageRouteTransitionMixin<T> {
102 } 102 }
103 103
104 final pageToBuild = middlewareRunner.runOnPageBuildStart(page)!; 104 final pageToBuild = middlewareRunner.runOnPageBuildStart(page)!;
105 - return middlewareRunner.runOnPageBuilt(pageToBuild()); 105 + Widget p;
  106 + if (pageToBuild is GetRouteAwarePageBuilder) {
  107 + p = pageToBuild(this);
  108 + } else {
  109 + p = pageToBuild();
  110 + }
  111 + return middlewareRunner.runOnPageBuilt(p);
106 } 112 }
107 113
108 @override 114 @override
@@ -182,3 +182,55 @@ class GetPage<T> extends Page<T> { @@ -182,3 +182,55 @@ class GetPage<T> extends Page<T> {
182 ).getPageToRoute<T>(this, unknownRoute); 182 ).getPageToRoute<T>(this, unknownRoute);
183 } 183 }
184 } 184 }
  185 +
  186 +class GetRouteAwarePage<T> extends GetPage<T> {
  187 + GetRouteAwarePage({
  188 + required String name,
  189 + required GetRouteAwarePageBuilder page,
  190 + bool? popGesture,
  191 + Map<String, String>? parameters,
  192 + String? title,
  193 + Transition? transition,
  194 + Curve curve = Curves.linear,
  195 + bool? participatesInRootNavigator,
  196 + Alignment? alignment,
  197 + bool maintainState = true,
  198 + bool opaque = true,
  199 + double Function(BuildContext context)? gestureWidth,
  200 + Bindings? binding,
  201 + List<Bindings> bindings = const [],
  202 + CustomTransition? customTransition,
  203 + Duration? transitionDuration,
  204 + bool fullscreenDialog = false,
  205 + bool preventDuplicates = true,
  206 + Object? arguments,
  207 + List<GetPage> children = const <GetPage>[],
  208 + List<GetMiddleware>? middlewares,
  209 + GetPage? unknownRoute,
  210 + bool showCupertinoParallax = true,
  211 + }) : super(
  212 + name: name,
  213 + page: page,
  214 + alignment: alignment,
  215 + arguments: arguments,
  216 + binding: binding,
  217 + bindings: bindings,
  218 + children: children,
  219 + curve: curve,
  220 + customTransition: customTransition,
  221 + fullscreenDialog: fullscreenDialog,
  222 + gestureWidth: gestureWidth,
  223 + maintainState: maintainState,
  224 + middlewares: middlewares,
  225 + opaque: opaque,
  226 + parameters: parameters,
  227 + participatesInRootNavigator: participatesInRootNavigator,
  228 + popGesture: popGesture,
  229 + preventDuplicates: preventDuplicates,
  230 + showCupertinoParallax: showCupertinoParallax,
  231 + title: title,
  232 + transition: transition,
  233 + transitionDuration: transitionDuration,
  234 + unknownRoute: unknownRoute,
  235 + );
  236 +}
1 import 'package:flutter/widgets.dart'; 1 import 'package:flutter/widgets.dart';
2 2
  3 +import 'default_route.dart';
  4 +
3 enum Transition { 5 enum Transition {
4 fade, 6 fade,
5 fadeIn, 7 fadeIn,
@@ -19,3 +21,4 @@ enum Transition { @@ -19,3 +21,4 @@ enum Transition {
19 } 21 }
20 22
21 typedef GetPageBuilder = Widget Function(); 23 typedef GetPageBuilder = Widget Function();
  24 +typedef GetRouteAwarePageBuilder<T> = Widget Function([GetPageRoute<T>? route]);