ModalBottomSheetRoute<T> class
A route that represents a Material Design modal bottom sheet.
A modal bottom sheet is an alternative to a menu or a dialog and prevents the user from interacting with the rest of the app.
A closely related widget is a persistent bottom sheet, which shows information that supplements the primary content of the app without preventing the user from interacting with the app. Persistent bottom sheets can be created and displayed with the showBottomSheet function or the ScaffoldState.showBottomSheet method.
The isScrollControlled parameter specifies whether this is a route for a bottom sheet that will utilize DraggableScrollableSheet. Consider setting this parameter to true if this bottom sheet has a scrollable child, such as a ListView or a GridView, to have the bottom sheet be draggable.
The isDismissible parameter specifies whether the bottom sheet will be dismissed when user taps on the scrim.
The enableDrag parameter specifies whether the bottom sheet can be dragged up and down and dismissed by swiping downwards.
The useSafeArea parameter specifies whether the sheet will avoid system intrusions on the top, left, and right. If false, no SafeArea is added; and MediaQuery.removePadding is applied to the top, so that system intrusions at the top will not be avoided by a SafeArea inside the bottom sheet either. Defaults to false.
The optional backgroundColor, elevation, shape, clipBehavior, constraints and transitionAnimationController parameters can be passed in to customize the appearance and behavior of modal bottom sheets (see the documentation for these on BottomSheet for more details).
The transitionAnimationController controls the bottom sheet's entrance and exit animations. It's up to the owner of the controller to call AnimationController.dispose when the controller is no longer needed.
The optional settings
parameter sets the RouteSettings of the modal bottom sheet
sheet. This is particularly useful in the case that a user wants to observe
PopupRoutes within a NavigatorObserver.
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 is
Offset.zero
, which will cause the content to appear in the top-left sub-screen. - for TextDirection.rtl, anchorPoint is
Offset(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.
See also:
- showModalBottomSheet, which is a way to display a ModalBottomSheetRoute.
- BottomSheet, which becomes the parent of the widget returned by the
function passed as the
builder
argument to showModalBottomSheet. - showBottomSheet and ScaffoldState.showBottomSheet, for showing non-modal bottom sheets.
- DraggableScrollableSheet, creates a bottom sheet that grows and then becomes scrollable once it reaches its maximum size.
- DisplayFeatureSubScreen, which documents the specifics of how DisplayFeatures can split the screen into sub-screens.
- The Material 2 spec at m2.material.io/components/sheets-bottom.
- The Material 3 spec at m3.material.io/components/bottom-sheets/overview.
- Inheritance
-
- Object
- Route<
T> - OverlayRoute<
T> - TransitionRoute<
T> - ModalRoute<
T> - PopupRoute<
T> - ModalBottomSheetRoute
Constructors
- ModalBottomSheetRoute({required WidgetBuilder builder, CapturedThemes? capturedThemes, String? barrierLabel, String? barrierOnTapHint, Color? backgroundColor, double? elevation, ShapeBorder? shape, Clip? clipBehavior, BoxConstraints? constraints, Color? modalBarrierColor, bool isDismissible = true, bool enableDrag = true, bool? showDragHandle, required bool isScrollControlled, double scrollControlDisabledMaxHeightRatio = _defaultScrollControlDisabledMaxHeightRatio, RouteSettings? settings, AnimationController? transitionAnimationController, Offset? anchorPoint, bool useSafeArea = false, AnimationStyle? sheetAnimationStyle})
- A modal bottom sheet route.
Properties
- allowSnapshotting → bool
-
Whether the route transition will prefer to animate a snapshot of the
entering/exiting routes.
no setterinherited
- anchorPoint → Offset?
-
The anchor point used to pick the closest sub-screen.
final
-
animation
→ Animation<
double> ? -
The animation that drives the route's transition and the previous route's
forward transition.
no setterinherited
- backgroundColor → Color?
-
The bottom sheet's background color.
final
- barrierColor → Color
-
The color to use for the modal barrier. If this is null, the barrier will
be transparent.
no setteroverride
- barrierCurve → Curve
-
The curve that is used for animating the modal barrier in and out.
no setterinherited
- barrierDismissible → bool
-
Whether you can dismiss this route by tapping the modal barrier.
no setteroverride
- barrierLabel → String?
-
The semantic label used for a dismissible 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
-
Whether this route can be popped.
no setterinherited
- 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
-
completed
→ Future<
T?> -
This future completes only once the transition itself has finished, after
the overlay entries have been removed from the navigator's overlay.
no setterinherited
- constraints → BoxConstraints?
-
Defines minimum and maximum sizes for a BottomSheet.
final
- controller → AnimationController?
-
The animation controller that the route uses to drive the transitions.
no setterinherited
- currentResult → T?
-
When this route is popped (see Navigator.pop) if the result isn't
specified or if it's null, this value will be used instead.
no setterinherited
- debugLabel → String
-
A short description of this route useful for debugging.
no setterinherited
- 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
- filter → ImageFilter?
-
The filter to add to the barrier.
finalinherited
- finishedWhenPopped → bool
-
Controls whether didPop calls NavigatorState.finalizeRoute.
no setterinherited
- hasActiveRouteBelow → bool
-
Whether there is at least one active route underneath this route.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasScopedWillPopCallback → bool
-
True if one or more WillPopCallback callbacks exist.
no setterinherited
- impliesAppBarDismissal → bool
-
Whether an AppBar in the route should automatically add a back button or
close button.
no setterinherited
- isActive → bool
-
Whether this route is on the navigator.
no setterinherited
- isCurrent → bool
-
Whether this route is the top-most route on the navigator.
no setterinherited
- isDismissible → bool
-
Specifies whether the bottom sheet will be dismissed
when user taps on the scrim.
final
- isFirst → bool
-
Whether this route is the bottom-most active route on the navigator.
no setterinherited
- isScrollControlled → bool
-
Specifies whether this is a route for a bottom sheet that will utilize
DraggableScrollableSheet.
final
- maintainState → bool
-
Whether the route should remain in memory when it is inactive.
no setterinherited
- modalBarrierColor → Color?
-
Specifies the color of the modal barrier that darkens everything below the
bottom sheet.
final
-
The navigator that the route is in, if any.
no setterinherited
- offstage ↔ bool
-
Whether this route is currently offstage.
getter/setter pairinherited
- opaque → bool
-
Whether the route obscures previous routes when the transition is complete.
no setterinherited
-
overlayEntries
→ List<
OverlayEntry> -
The overlay entries of this route.
no setterinherited
- popDisposition → RoutePopDisposition
-
Returns RoutePopDisposition.doNotPop if any of the PopEntry instances
registered with registerPopEntry have PopEntry.canPopNotifier set to
false.
no setterinherited
- popGestureEnabled → bool
-
Whether a pop gesture can be started by the user for this route.
no setterinherited
- popGestureInProgress → bool
-
True if a back gesture (iOS-style back swipe or Android predictive back)
is currently underway for this route.
no setterinherited
-
popped
→ Future<
T?> -
A future that completes when this route is popped off the navigator.
no setterinherited
-
restorationScopeId
→ ValueListenable<
String?> -
The restoration scope ID to be used for the RestorationScope surrounding
this route.
no setterinherited
- reverseTransitionDuration → Duration
-
The duration the transition going in reverse.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollControlDisabledMaxHeightRatio → double
-
The max height constraint ratio for the bottom sheet
when isScrollControlled is set to false,
no ratio will be applied when isScrollControlled is set to true.
final
-
secondaryAnimation
→ Animation<
double> ? -
The animation for the route being pushed on top of this route. This
animation lets this route coordinate with the entrance and exit transition
of route pushed on top of this route.
no setterinherited
- semanticsDismissible → bool
-
Whether the semantics of the modal barrier are included in the
semantics tree.
no setterinherited
- settings → RouteSettings
-
The settings for this route.
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
- subtreeContext → BuildContext?
-
The build context for the subtree containing the primary content of this route.
no setterinherited
- transitionAnimationController → AnimationController?
-
The animation controller that controls the bottom sheet's entrance and
exit animations.
final
- transitionDuration → Duration
-
The duration the transition going forwards.
no setteroverride
- traversalEdgeBehavior → TraversalEdgeBehavior?
-
Controls the transfer of focus beyond the first and the last items of a
FocusScopeNode.
finalinherited
- useSafeArea → bool
-
Whether to avoid system intrusions on the top, left, and right.
final
- willDisposeAnimationController ↔ bool
-
Whether to takeover the controller created by createAnimationController.
getter/setter pairinherited
- willHandlePopInternally → bool
-
Whether calling didPop would return false.
no setterinherited
Methods
-
addLocalHistoryEntry(
LocalHistoryEntry entry) → void -
Adds a local history entry to this route.
inherited
-
addScopedWillPopCallback(
WillPopCallback callback) → void -
Enables this route to veto attempts by the user to dismiss it.
inherited
-
buildModalBarrier(
) → Widget -
Build the barrier for this ModalRoute, subclasses can override
this method to create their own barrier with customized features such as
color or accessibility focus size.
override
-
buildPage(
BuildContext context, Animation< double> animation, Animation<double> secondaryAnimation) → Widget -
Override this method to build the primary content of this route.
override
-
buildTransitions(
BuildContext context, Animation< double> animation, Animation<double> secondaryAnimation, Widget child) → Widget -
Override this method to wrap the
child
with one or more transition widgets that define how the route arrives on and leaves the screen.inherited -
canTransitionFrom(
TransitionRoute previousRoute) → bool -
Returns true if
previousRoute
should animate when this route is pushed on top of it or when then this route is popped off of it.inherited -
canTransitionTo(
TransitionRoute nextRoute) → bool -
Returns true if this route supports a transition animation that runs
when
nextRoute
is pushed on top of it or whennextRoute
is popped off of it.inherited -
changedExternalState(
) → void -
Called whenever the Navigator has updated in some manner that might
affect routes, to indicate that the route may wish to rebuild as well.
inherited
-
changedInternalState(
) → void -
Called whenever the internal state of the route has changed.
inherited
-
createAnimation(
) → Animation< double> -
Called to create the animation that exposes the current progress of
the transition controlled by the animation controller created by
createAnimationController().
inherited
-
createAnimationController(
) → AnimationController -
Called to create the animation controller that will drive the transitions to
this route from the previous one, and back to the previous route from this
one.
override
-
createOverlayEntries(
) → Iterable< OverlayEntry> -
Subclasses should override this getter to return the builders for the overlay.
inherited
-
didAdd(
) → void -
Called after install when the route is added to the navigator.
inherited
-
didChangeNext(
Route? nextRoute) → void -
This route's next route has changed to the given new route.
inherited
-
didChangePrevious(
Route? previousRoute) → void -
This route's previous route has changed to the given new route.
inherited
-
didComplete(
T? result) → void -
The route was popped or is otherwise being removed somewhat gracefully.
inherited
-
didPop(
T? result) → bool -
A request was made to pop this route. If the route can handle it
internally (e.g. because it has its own stack of internal state) then
return false, otherwise return true (by returning the value of calling
super.didPop
). Returning false will prevent the default behavior of NavigatorState.pop.inherited -
didPopNext(
Route nextRoute) → void -
The given route, which was above this one, has been popped off the
navigator.
inherited
-
didPush(
) → TickerFuture -
Called after install when the route is pushed onto the navigator.
inherited
-
didReplace(
Route? oldRoute) → void -
Called after install when the route replaced another in the navigator.
inherited
-
dispose(
) → void -
Discards any resources used by the object.
override
-
handleCancelBackGesture(
) → void -
Handles a predictive back gesture ending in cancellation.
inherited
-
handleCommitBackGesture(
) → void -
Handles a predictive back gesture ending successfully.
inherited
-
handleStartBackGesture(
{double progress = 0.0}) → void -
Handles a predictive back gesture starting.
inherited
-
handleUpdateBackGestureProgress(
{required double progress}) → void -
Handles a predictive back gesture updating as the user drags across the
screen.
inherited
-
install(
) → void -
Called when the route is inserted into the navigator.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onPopInvoked(
bool didPop) → void -
Called after a route pop was handled.
inherited
-
onPopInvokedWithResult(
bool didPop, T? result) → void -
Called after a route pop was handled.
inherited
-
registerPopEntry(
PopEntry< Object?> popEntry) → void -
Registers the existence of a PopEntry in the route.
inherited
-
removeLocalHistoryEntry(
LocalHistoryEntry entry) → void -
Remove a local history entry from this route.
inherited
-
removeScopedWillPopCallback(
WillPopCallback callback) → void -
Remove one of the callbacks run by willPop.
inherited
-
setState(
VoidCallback fn) → void -
Schedule a call to buildTransitions.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
unregisterPopEntry(
PopEntry< Object?> popEntry) → void -
Unregisters a PopEntry in the route's widget subtree.
inherited
-
willPop(
) → Future< RoutePopDisposition> -
Returns RoutePopDisposition.doNotPop if any of callbacks added with
addScopedWillPopCallback returns either false or null. If they all
return true, the base Route.willPop's result will be returned. The
callbacks will be called in the order they were added, and will only be
called if all previous callbacks returned true.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited