showPopupDialog<T> function
Future<T?>
showPopupDialog<T>(
})
Implementation
Future<T?> showPopupDialog<T>(
BuildContext context,
WidgetBuilder builder, {
bool useRootNavigator = false,
bool barrierDismissible = true,
Color? barrierColor,
String? barrierLabel,
bool asDropDown = false,
bool useTargetWidth = false,
double? dialogWidth,
}) {
final navigator = Navigator.of(context, rootNavigator: useRootNavigator);
final renderBox = context.findRenderObject()! as RenderBox;
final overlayRenderBox =
navigator.overlay!.context.findRenderObject()! as RenderBox;
final position = RelativeRect.fromRect(
Rect.fromPoints(
renderBox.localToGlobal(renderBox.size.topLeft(Offset.zero),
ancestor: overlayRenderBox),
renderBox.localToGlobal(renderBox.size.bottomRight(Offset.zero),
ancestor: overlayRenderBox),
),
Offset.zero & overlayRenderBox.size,
);
return navigator.push(_PopupDialogRoute<T>(
asDropDown: asDropDown,
position: position,
capturedThemes:
InheritedTheme.capture(from: context, to: navigator.context),
dialogWidth: useTargetWidth ? renderBox.size.width : dialogWidth,
barrierDismissible: barrierDismissible,
barrierColor: barrierColor,
barrierLabel: barrierLabel,
child: builder(context),
));
}