appBuilder static method
Widget
appBuilder(
- BuildContext context,
- Widget? child, {
- BorderRadius? borderRadius,
- bool shouldBounceOnTap = true,
- Color backgroundColor = Colors.black,
- bool showDebugPrints = false,
Hook for MaterialApp.builder / WidgetsApp.builder.
This is the supported way to ensure _ActivatorWidget becomes a parent
of your app's widget tree (no overlays, no runtime re-parenting).
Usage:
MaterialApp(
builder: Modal.appBuilder,
home: ...,
)
Implementation
static Widget appBuilder(
/// The build context of the app
BuildContext context,
/// The child widget: the app background behind the modal
Widget? child, {
/// The border radius to apply to the modal's corners when [ModalType] is [ModalType.sheet] and when a sheet is active/showing
BorderRadius? borderRadius,
/// Whether the modal background should bounce when the dismiss barrier is tapped
bool shouldBounceOnTap = true,
/// The background color when [ModalType.sheet] sheet is active/showing, when the background layer is scaled
Color backgroundColor = Colors.black,
/// Whether to show debug prints for modal events
bool showDebugPrints = false,
}) {
assert(
child != null,
'Modal.appBuilder requires the MaterialApp/WidgetsApp builder child. '
'Make sure your app builder passes the provided child into Modal.appBuilder.',
);
_appBuilderInstalled = true;
_showDebugPrints = showDebugPrints;
return _ActivatorWidget(
borderRadius: borderRadius ?? BorderRadius.zero,
shouldBounce: shouldBounceOnTap,
backgroundColor: backgroundColor,
child: child ?? const SizedBox.shrink(),
);
}