showArnaPopupDialog<T> function
- required BuildContext context,
- String? title,
- List<
ArnaHeaderBarItem> ? actions, - required WidgetBuilder builder,
- bool resizeToAvoidBottomInset = true,
- bool barrierDismissible = false,
- Color? barrierColor,
- String? barrierLabel,
- bool useSafeArea = true,
- RouteSettings? routeSettings,
- Offset? anchorPoint,
Displays a dialog in desktop and tablet mode and a new page on phones.
In desktop and tablet mode content below the dialog is dimmed with a ModalBarrier.
This function takes a builder
which is used to build the dialog and body
widgets.
Content below the dialog is dimmed with a ModalBarrier.
The widget returned by the builder
does not share a context with the
location that showArnaPopupDialog is originally called from. Use a
StatefulBuilder or a custom StatefulWidget if the it needs to update
dynamically.
The context
argument is used to look up the Navigator for the dialog. It
is only used when the method is called. Its corresponding widget can be
safely removed from the tree before the dialog is closed.
The barrierDismissible
argument is used to indicate whether tapping on the
barrier will dismiss the dialog. It is true
by default and can not be
null
.
The barrierColor
argument is used to specify the color of the modal
barrier that darkens everything below the dialog. If null
the default
color ArnaColors.barrierColor is used.
The useSafeArea
argument is used to indicate if the dialog should only
display in 'safe' areas of the screen not used by the operating system (see
SafeArea for more details). It is true
by default, which means the
dialog will not overlap operating system areas. If it is set to false
the
dialog will only be constrained by the screen size. It can not be null
.
The useRootNavigator
argument is used to determine whether to push the
dialog to the Navigator furthest from or nearest to the given context
.
By default, useRootNavigator
is true and the dialog route created by this
method is pushed to the root navigator.
The routeSettings
argument is passed to showGeneralDialog, see
RouteSettings for details.
A DisplayFeature can split the screen into sub-screens. The closest one to
anchorPoint
is used to render the content.
If no anchorPoint
is provided, then Directionality is used:
- for TextDirection.ltr,
anchorPoint
isOffset.zero
, which will cause the content to appear in the top-left sub-screen. - for TextDirection.rtl,
anchorPoint
isOffset(double.maxFinite, 0)
, which will cause the content to appear in the top-right sub-screen.
If no anchorPoint
is provided, and there is no Directionality ancestor
widget in the tree, then the widget asserts during build in debug mode.
If the application has multiple Navigator objects, it may be necessary to
call Navigator.of(context, rootNavigator: true).pop(result)
to close the
dialog rather than just Navigator.pop(context, result)
.
Returns a Future that resolves to the value (if any) that was passed to Navigator.pop when the dialog was closed.
See also:
_ArnaPopupDialog
, which displays a dialog box in desktop and tablet mode._ArnaPopupPage
, which displays a page in phone mode.- showGeneralDialog, which allows for customization of the dialog popup.
- DisplayFeatureSubScreen, which documents the specifics of how DisplayFeatures can split the screen into sub-screens.
Implementation
Future<T?> showArnaPopupDialog<T>({
required BuildContext context,
String? title,
List<ArnaHeaderBarItem>? actions,
required WidgetBuilder builder,
bool resizeToAvoidBottomInset = true,
bool barrierDismissible = false,
Color? barrierColor,
String? barrierLabel,
bool useSafeArea = true,
bool useRootNavigator = true,
RouteSettings? routeSettings,
Offset? anchorPoint,
}) {
return ArnaHelpers.isCompact(context)
? Navigator.of(context).push(
ArnaPageRoute<T>(
builder: (BuildContext context) => _ArnaPopupPage(
title: title,
actions: actions,
body: Builder(builder: builder),
resizeToAvoidBottomInset: resizeToAvoidBottomInset,
),
),
)
: showGeneralDialog(
context: context,
pageBuilder: (
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
) {
final Widget dialog = _ArnaPopupDialog(
title: title,
actions: actions,
body: Builder(builder: builder),
);
return useSafeArea ? SafeArea(child: dialog) : dialog;
},
barrierDismissible: barrierDismissible,
barrierLabel: barrierLabel ??
MaterialLocalizations.of(context).modalBarrierDismissLabel,
barrierColor: barrierColor ?? ArnaColors.barrierColor,
transitionDuration: Styles.basicDuration,
transitionBuilder: (
BuildContext context,
Animation<double> animation,
_,
Widget child,
) {
return ScaleTransition(
scale: CurvedAnimation(
parent: animation,
curve: Styles.basicCurve,
),
child: ArnaFadeTransition.fadeIn(child, animation),
);
},
useRootNavigator: useRootNavigator,
routeSettings: routeSettings,
anchorPoint: anchorPoint,
);
}