Ahmed Fwela

Added GetRouteAwarePageBuilder

... ... @@ -102,7 +102,13 @@ class GetPageRoute<T> extends PageRoute<T> with GetPageRouteTransitionMixin<T> {
}
final pageToBuild = middlewareRunner.runOnPageBuildStart(page)!;
return middlewareRunner.runOnPageBuilt(pageToBuild());
Widget p;
if (pageToBuild is GetRouteAwarePageBuilder) {
p = pageToBuild(this);
} else {
p = pageToBuild();
}
return middlewareRunner.runOnPageBuilt(p);
}
@override
... ...
... ... @@ -182,3 +182,55 @@ class GetPage<T> extends Page<T> {
).getPageToRoute<T>(this, unknownRoute);
}
}
class GetRouteAwarePage<T> extends GetPage<T> {
GetRouteAwarePage({
required String name,
required GetRouteAwarePageBuilder page,
bool? popGesture,
Map<String, String>? parameters,
String? title,
Transition? transition,
Curve curve = Curves.linear,
bool? participatesInRootNavigator,
Alignment? alignment,
bool maintainState = true,
bool opaque = true,
double Function(BuildContext context)? gestureWidth,
Bindings? binding,
List<Bindings> bindings = const [],
CustomTransition? customTransition,
Duration? transitionDuration,
bool fullscreenDialog = false,
bool preventDuplicates = true,
Object? arguments,
List<GetPage> children = const <GetPage>[],
List<GetMiddleware>? middlewares,
GetPage? unknownRoute,
bool showCupertinoParallax = true,
}) : super(
name: name,
page: page,
alignment: alignment,
arguments: arguments,
binding: binding,
bindings: bindings,
children: children,
curve: curve,
customTransition: customTransition,
fullscreenDialog: fullscreenDialog,
gestureWidth: gestureWidth,
maintainState: maintainState,
middlewares: middlewares,
opaque: opaque,
parameters: parameters,
participatesInRootNavigator: participatesInRootNavigator,
popGesture: popGesture,
preventDuplicates: preventDuplicates,
showCupertinoParallax: showCupertinoParallax,
title: title,
transition: transition,
transitionDuration: transitionDuration,
unknownRoute: unknownRoute,
);
}
... ...
import 'package:flutter/widgets.dart';
import 'default_route.dart';
enum Transition {
fade,
fadeIn,
... ... @@ -19,3 +21,4 @@ enum Transition {
}
typedef GetPageBuilder = Widget Function();
typedef GetRouteAwarePageBuilder<T> = Widget Function([GetPageRoute<T>? route]);
... ...