ModalBottomSheetPage<T> class
A declarative page-based modal bottom sheet that can be used with Navigator 2.0.
This page creates a ModalBottomSheetRoute when added to the Navigator's pages list. It provides all the functionality of showModalBottomSheet but in a declarative way.
Example usage:
Navigator(
pages: [
MaterialPage(child: HomePage()),
if (showBottomSheet)
ModalBottomSheetPage(
builder: (context) => MyBottomSheetContent(),
),
],
onPopPage: (route, result) {
if (!route.didPop(result)) return false;
// Update your state here
return true;
},
)
- Inheritance
-
- Object
- RouteSettings
- Page<
T> - ModalBottomSheetPage
Constructors
- ModalBottomSheetPage.new({required WidgetBuilder builder, Color? backgroundColor, double? elevation, ShapeBorder? shape, Clip? clipBehavior, String? barrierLabel, String? barrierOnTapHint, CapturedThemes? capturedThemes, Color? modalBarrierColor, bool isDismissible = true, bool enableDrag = true, bool? showDragHandle, double? maxHeightRatio, AnimationController? transitionAnimationController, AnimationStyle? sheetAnimationStyle, bool useSafeArea = false, bool isScrollControlled = false, Offset? anchorPoint, BoxConstraints? constraints, bool? requestFocus, VoidCallback? onBarrierTap, LocalKey? key, String? name, Object? arguments, String? restorationId})
-
Creates a modal bottom sheet page.
const
- ModalBottomSheetPage.withContext({required BuildContext context, required WidgetBuilder builder, Color? backgroundColor, double? elevation, ShapeBorder? shape, Clip? clipBehavior, String? barrierLabel, String? barrierOnTapHint, Color? modalBarrierColor, bool isDismissible = true, bool enableDrag = true, bool? showDragHandle, double? maxHeightRatio, AnimationController? transitionAnimationController, AnimationStyle? sheetAnimationStyle, bool useSafeArea = false, bool isScrollControlled = false, Offset? anchorPoint, BoxConstraints? constraints, bool? requestFocus, VoidCallback? onBarrierTap, LocalKey? key, String? name, Object? arguments, String? restorationId})
-
Creates a modal bottom sheet page with automatically captured themes.
factory
Properties
- anchorPoint → Offset?
-
The anchor point used to pick the closest sub-screen.
final
- arguments → Object?
-
The arguments passed to this route.
finalinherited
- backgroundColor → Color?
-
The bottom sheet's background color.
final
- barrierLabel → String?
-
The semantic label used for the barrier.
final
- barrierOnTapHint → String?
-
The semantic hint text that informs users what will happen if they
tap on the widget. Announced in the format of 'Double tap to ...'.
final
- builder → WidgetBuilder
-
A builder for the contents of the sheet.
final
- canPop → bool
-
When false, blocks the associated route from being popped.
finalinherited
- capturedThemes → CapturedThemes?
-
Stores a list of captured InheritedThemes that are wrapped around the
bottom sheet.
final
- clipBehavior → Clip?
-
The content will be clipped (or not) according to this option.
final
- constraints → BoxConstraints?
-
Defines minimum and maximum sizes for a BottomSheet.
final
- elevation → double?
-
The z-coordinate at which to place this material relative to its parent.
final
- enableDrag → bool
-
Specifies whether the bottom sheet can be dragged up and down
and dismissed by swiping downwards.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDismissible → bool
-
Specifies whether the bottom sheet will be dismissed
when user taps on the scrim.
final
- isScrollControlled → bool
-
Specifies whether this is a route for a bottom sheet that will utilize
DraggableScrollableSheet.
final
- key → LocalKey?
-
The key associated with this page.
finalinherited
- maxHeightRatio → double?
-
The max height constraint ratio for the bottom sheet
when isScrollControlled is set to false.
final
- modalBarrierColor → Color?
-
Specifies the color of the modal barrier that darkens everything below the
bottom sheet.
final
- name → String?
-
The name of the route (e.g., "/settings").
finalinherited
- onBarrierTap → VoidCallback?
-
Custom callback when the barrier is tapped.
final
-
onPopInvoked
→ PopInvokedWithResultCallback<
T> -
Called after a pop on the associated route was handled.
finalinherited
- requestFocus → bool?
-
Whether to request focus when the bottom sheet is shown.
final
- restorationId → String?
-
Restoration ID to save and restore the state of the Route configured by
this page.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shape → ShapeBorder?
-
The shape of the bottom sheet.
final
- sheetAnimationStyle → AnimationStyle?
-
Used to override the modal bottom sheet animation duration and reverse
animation duration.
final
- showDragHandle → bool?
-
Specifies whether a drag handle is shown.
final
- transitionAnimationController → AnimationController?
-
The animation controller that controls the bottom sheet's entrance and
exit animations.
final
- useSafeArea → bool
-
Whether to avoid system intrusions on the top, left, and right.
final
Methods
-
canUpdate(
Page other) → bool -
Whether this page can be updated with the
other
page.inherited -
createRoute(
BuildContext context) → Route< T> -
Creates the Route that corresponds to this page.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited