showModalWithKey<T> method
Future<T?>
showModalWithKey<T>({
- required WidgetBuilder builder,
- bool barrierDismissible = true,
- Color? barrierColor = Colors.black54,
- String? barrierLabel,
- bool useSafeArea = true,
- RouteSettings? routeSettings,
- Offset? anchorPoint,
- TraversalEdgeBehavior? traversalEdgeBehavior,
Implementation
Future<T?> showModalWithKey<T>({
required WidgetBuilder builder,
bool barrierDismissible = true,
Color? barrierColor = Colors.black54,
String? barrierLabel,
bool useSafeArea = true,
bool useRootNavigator = true,
RouteSettings? routeSettings,
Offset? anchorPoint,
TraversalEdgeBehavior? traversalEdgeBehavior,
GlobalKey<NavigatorState>? navKey,
}) {
assert(
useRootNavigator == true || navKey != null,
"If useRootNavigator is false, a navKey must be provided.",
);
final navKey0 = useRootNavigator ? _navigatorKey : navKey!;
if (navKey0.currentContext == null || navKey0.currentState == null) {
return Future.value(null);
}
return navKey0.currentState!.push<T>(
DialogRoute(
context: navKey0.currentContext!,
builder: builder,
barrierColor: barrierColor,
barrierDismissible: barrierDismissible,
barrierLabel: barrierLabel,
useSafeArea: useSafeArea,
settings: routeSettings,
anchorPoint: anchorPoint,
traversalEdgeBehavior:
traversalEdgeBehavior ?? TraversalEdgeBehavior.closedLoop,
),
);
}