showFDialog<T> function

Future<T?> showFDialog<T>({
  1. required BuildContext context,
  2. required Widget builder(
    1. BuildContext,
    2. FDialogStyle,
    3. Animation<double>
    ),
  3. bool useRootNavigator = false,
  4. FDialogStyle style(
    1. FDialogStyle
    )?,
  5. String? barrierLabel,
  6. bool barrierDismissible = true,
  7. RouteSettings? routeSettings,
  8. AnimationController? transitionAnimationController,
  9. Offset? anchorPoint,
  10. bool useSafeArea = false,
})

Shows a dialog.

context is used to look up the Navigator and FDialogStyle for the dialog. It is only used when the method is called. Its corresponding widget can be safely removed from the tree before the sheet is closed.

useRootNavigator ensures that the root navigator displays the sheet when true. This is useful in the case that a modal sheet needs to be displayed above all other content but the caller is inside another Navigator.

style defaults to FDialogStyle from the closest FTheme ancestor.

barrierLabel defaults to FLocalizations.barrierLabel.

Returns a Future that resolves to the value (if any) that was passed to Navigator.pop when the modal sheet was closed.

CLI

To generate and customize this widget's style:

dart run forui style create dialog

See:

Implementation

Future<T?> showFDialog<T>({
  required BuildContext context,
  required Widget Function(BuildContext, FDialogStyle, Animation<double>) builder,
  bool useRootNavigator = false,
  FDialogStyle Function(FDialogStyle)? style,
  String? barrierLabel,
  bool barrierDismissible = true,
  RouteSettings? routeSettings,
  AnimationController? transitionAnimationController,
  Offset? anchorPoint,
  bool useSafeArea = false,
}) {
  assert(debugCheckHasMediaQuery(context));

  final navigator = Navigator.of(context, rootNavigator: useRootNavigator);
  final localizations = FLocalizations.of(context) ?? FDefaultLocalizations();
  final dialogStyle = style?.call(context.theme.dialogStyle) ?? context.theme.dialogStyle;

  return navigator.push(
    FDialogRoute<T>(
      style: dialogStyle,
      builder: (context, animation) => builder(context, dialogStyle, animation),
      capturedThemes: InheritedTheme.capture(from: context, to: navigator.context),
      barrierDismissible: barrierDismissible,
      barrierLabel: barrierLabel ?? localizations.barrierLabel,
      barrierOnTapHint: localizations.barrierOnTapHint(localizations.dialogSemanticsLabel),
      settings: routeSettings,
      anchorPoint: anchorPoint,
      useSafeArea: useSafeArea,
    ),
  );
}