Skip to main content

ModalRoute

Trait ModalRoute 

Source
pub trait ModalRoute: LocalHistoryRoute {
Show 42 methods // Required methods fn modal_route_data(self: Handle<Self>, app: &App) -> &ModalRouteData; fn modal_route_data_mut( self: Handle<Self>, app: &mut App, ) -> &mut ModalRouteData; fn build_page( self: Handle<Self>, app: &mut App, context: BuildContext, animation: AnimationRef<f64>, secondary_animation: AnimationRef<f64>, ) -> WidgetRef; fn barrier_dismissible(self: Handle<Self>, app: &App) -> bool; fn barrier_color(self: Handle<Self>, app: &App) -> Option<Color>; fn barrier_label(self: Handle<Self>, app: &App) -> Option<String>; fn maintain_state(self: Handle<Self>, app: &App) -> bool; // Provided methods fn as_modal_route(self: Handle<Self>) -> AnyModalRoute { ... } fn set_state( self: Handle<Self>, app: &mut App, change: impl FnOnce(&mut App), ) { ... } fn build_transitions( self: Handle<Self>, app: &mut App, context: BuildContext, animation: AnimationRef<f64>, secondary_animation: AnimationRef<f64>, child: WidgetRef, ) -> WidgetRef { ... } fn delegated_transition( self: Handle<Self>, app: &App, ) -> Option<DelegatedTransitionBuilder> { ... } fn build_flexible_transitions( self: Handle<Self>, app: &mut App, context: BuildContext, animation: AnimationRef<f64>, secondary_animation: AnimationRef<f64>, child: WidgetRef, ) -> WidgetRef { ... } fn install(self: Handle<Self>, app: &mut App) { ... } fn did_push(self: Handle<Self>, app: &mut App) -> TickerFuture ⓘ { ... } fn did_add(self: Handle<Self>, app: &mut App) { ... } fn semantics_dismissible(self: Handle<Self>, app: &App) -> bool { ... } fn barrier_curve(self: Handle<Self>, app: &App) -> Rc<dyn Curve> { ... } fn pop_gesture_in_progress(self: Handle<Self>, app: &App) -> bool { ... } fn pop_gesture_enabled(self: Handle<Self>, app: &mut App) -> bool { ... } fn offstage(self: Handle<Self>, app: &App) -> bool { ... } fn set_offstage(self: Handle<Self>, app: &mut App, value: bool) { ... } fn subtree_context( self: Handle<Self>, app: &mut App, ) -> Option<BuildContext> { ... } fn animation(self: Handle<Self>, app: &App) -> Option<AnyAnimation<f64>> { ... } fn secondary_animation( self: Handle<Self>, app: &App, ) -> Option<AnyAnimation<f64>> { ... } fn pop_disposition(self: Handle<Self>, app: &mut App) -> RoutePopDisposition { ... } fn on_pop_invoked_with_result( self: Handle<Self>, app: &mut App, did_pop: bool, result: RouteResult, ) { ... } fn register_pop_entry( self: Handle<Self>, app: &mut App, pop_entry: Rc<dyn PopEntry>, ) { ... } fn unregister_pop_entry( self: Handle<Self>, app: &mut App, pop_entry: Rc<dyn PopEntry>, ) { ... } fn maybe_dispatch_navigation_notification(self: Handle<Self>, app: &mut App) { ... } fn did_change_previous( self: Handle<Self>, app: &mut App, previous_route: Option<AnyRoute>, ) { ... } fn did_change_next( self: Handle<Self>, app: &mut App, next_route: Option<AnyRoute>, ) { ... } fn did_pop_next(self: Handle<Self>, app: &mut App, next_route: AnyRoute) { ... } fn update_received_transition( self: Handle<Self>, app: &mut App, next_route: Option<AnyRoute>, ) { ... } fn changed_internal_state(self: Handle<Self>, app: &mut App) { ... } fn changed_external_state(self: Handle<Self>, app: &mut App) { ... } fn can_pop(self: Handle<Self>, app: &mut App) -> bool { ... } fn implies_app_bar_dismissal(self: Handle<Self>, app: &App) -> bool { ... } fn fullscreen_dialog(self: Handle<Self>, app: &App) -> bool { ... } fn build_modal_barrier_entry( self: Handle<Self>, app: &mut App, context: BuildContext, ) -> WidgetRef { ... } fn build_modal_barrier( self: Handle<Self>, app: &mut App, context: BuildContext, ) -> WidgetRef { ... } fn build_modal_scope( self: Handle<Self>, app: &mut App, context: BuildContext, ) -> WidgetRef { ... } fn create_overlay_entries( self: Handle<Self>, app: &mut App, ) -> Vec<Ref<OverlayEntry>> { ... }
}
Expand description

A route that blocks interaction with previous routes.

ModalRoutes cover the entire Navigator. They are not necessarily opaque, however; for example, a pop-up menu uses a ModalRoute but only shows the menu in a small box overlapping the previous route.

See also:

  • Route, which further documents the meaning of Dart’s T generic type argument.

Required Methods§

Source

fn modal_route_data(self: Handle<Self>, app: &App) -> &ModalRouteData

Dart’s ModalRoute fields, held under the field modal_route (modal_route_accessors!).

Source

fn modal_route_data_mut( self: Handle<Self>, app: &mut App, ) -> &mut ModalRouteData

Source

fn build_page( self: Handle<Self>, app: &mut App, context: BuildContext, animation: AnimationRef<f64>, secondary_animation: AnimationRef<f64>, ) -> WidgetRef

Override this method to build the primary content of this route.

The arguments have the following meanings:

  • context: The context in which the route is being built.
  • animation: The animation for this route’s transition. When entering, the animation runs forward from 0.0 to 1.0. When exiting, it runs backwards from 1.0 to 0.0.
  • secondary_animation: The animation for the route being pushed on top of this route.

This method is only called when the route is first built, and rarely thereafter. In particular, it is not automatically called again when the route’s state changes unless it uses AnyModalRoute::of. For a builder that is called every time the route’s state changes, consider build_transitions.

Source

fn barrier_dismissible(self: Handle<Self>, app: &App) -> bool

Whether you can dismiss this route by tapping the modal barrier.

The modal barrier is the scrim that is rendered behind each route, which generally prevents the user from interacting with the route below the current route, and normally partially obscures such routes.

If barrier_dismissible is true, then tapping this barrier, pressing the escape key on the keyboard, or calling route popping functions such as Navigator::pop will cause the current route to be popped with no value.

If this getter would ever start returning a different value, either changed_internal_state or changed_external_state should be invoked so that the change can take effect.

Source

fn barrier_color(self: Handle<Self>, app: &App) -> Option<Color>

The color to use for the modal barrier. If this is None, the barrier will be transparent.

The color is ignored, and the barrier made invisible, when offstage is true.

While the route is animating into position, the color is animated from transparent to the specified color.

Source

fn barrier_label(self: Handle<Self>, app: &App) -> Option<String>

The semantic label used for a dismissible barrier.

Source

fn maintain_state(self: Handle<Self>, app: &App) -> bool

Whether the route should remain in memory when it is inactive.

If this is true, then the route is maintained, so that any completions it is holding from the next route will properly resolve when the next route pops. If this is not necessary, this can be set to false to allow the framework to entirely discard the route’s widget hierarchy when it is not visible.

Provided Methods§

Source

fn as_modal_route(self: Handle<Self>) -> AnyModalRoute

This route as the erased AnyModalRoute.

Source

fn set_state(self: Handle<Self>, app: &mut App, change: impl FnOnce(&mut App))

Schedules a call to build_transitions.

Whenever you need to change internal state for a ModalRoute object, make the change in the closure you pass to set_state. If you just change the state directly without calling set_state, then the route will not be scheduled for rebuilding, meaning that its rendering will not be updated.

Source

fn build_transitions( self: Handle<Self>, app: &mut App, context: BuildContext, animation: AnimationRef<f64>, secondary_animation: AnimationRef<f64>, child: WidgetRef, ) -> WidgetRef

Override this method to wrap the child with one or more transition widgets that define how the route arrives on and leaves the screen.

By default, the child (which contains the widget returned by build_page) is not wrapped in any transition widgets.

This method, in contrast to build_page, is called each time the route’s state changes while it is visible.

Source

fn delegated_transition( self: Handle<Self>, app: &App, ) -> Option<DelegatedTransitionBuilder>

The DelegatedTransitionBuilder provided to the route below this one in the navigation stack.

Used for the purposes of coordinating transitions between two routes with different route transitions. When a route is added to the stack, the original topmost route will look for this transition, and if available, it will use it to animate off the screen.

If the builder returns None, then by default the original transition of the routes will be used.

The ModalRoute receiving this transition sets it as its received_transition.

Source

fn build_flexible_transitions( self: Handle<Self>, app: &mut App, context: BuildContext, animation: AnimationRef<f64>, secondary_animation: AnimationRef<f64>, child: WidgetRef, ) -> WidgetRef

Dart’s _buildFlexibleTransitions: wraps the transitions of this route with the received_transition, when there is one.

Source

fn install(self: Handle<Self>, app: &mut App)

Dart’s ModalRoute.install.

Source

fn did_push(self: Handle<Self>, app: &mut App) -> TickerFuture ⓘ

Dart’s ModalRoute.didPush.

Source

fn did_add(self: Handle<Self>, app: &mut App)

Dart’s ModalRoute.didAdd.

Source

fn semantics_dismissible(self: Handle<Self>, app: &App) -> bool

Whether the semantics of the modal barrier are included in the semantics tree.

Source

fn barrier_curve(self: Handle<Self>, app: &App) -> Rc<dyn Curve>

The curve that is used for animating the modal barrier in and out.

It defaults to Curves::ease.

Source

fn pop_gesture_in_progress(self: Handle<Self>, app: &App) -> bool

True if a back gesture (iOS-style back swipe or Android predictive back) is currently underway for this route.

Source

fn pop_gesture_enabled(self: Handle<Self>, app: &mut App) -> bool

Dart’s ModalRoute.popGestureEnabled.

Source

fn offstage(self: Handle<Self>, app: &App) -> bool

Whether this route is currently offstage.

On the first frame of a route’s entrance transition, the route is built Offstage using an animation progress of 1.0. The route is invisible and non-interactive, but each widget has its final size and position. This mechanism lets the HeroController determine the final location of any hero widgets being animated as part of the transition.

The modal barrier, if any, is not rendered if offstage is true.

Whenever this changes value, changed_internal_state is called.

Source

fn set_offstage(self: Handle<Self>, app: &mut App, value: bool)

Sets offstage.

Source

fn subtree_context(self: Handle<Self>, app: &mut App) -> Option<BuildContext>

The build context for the subtree containing the primary content of this route.

Source

fn animation(self: Handle<Self>, app: &App) -> Option<AnyAnimation<f64>>

Dart’s ModalRoute.animation.

Source

fn secondary_animation( self: Handle<Self>, app: &App, ) -> Option<AnyAnimation<f64>>

Dart’s ModalRoute.secondaryAnimation.

Source

fn pop_disposition(self: Handle<Self>, app: &mut App) -> RoutePopDisposition

Dart’s ModalRoute.popDisposition.

Returns RoutePopDisposition::DoNotPop if any of the PopEntry instances registered with register_pop_entry have their PopEntry::can_pop_notifier set to false.

Source

fn on_pop_invoked_with_result( self: Handle<Self>, app: &mut App, did_pop: bool, result: RouteResult, )

Dart’s ModalRoute.onPopInvokedWithResult.

Source

fn register_pop_entry( self: Handle<Self>, app: &mut App, pop_entry: Rc<dyn PopEntry>, )

Registers the existence of a PopEntry in the route.

PopEntry instances registered in this way will have their PopEntry::on_pop_invoked_with_result callbacks called when a route is popped or a pop is attempted. They will also be able to block pop operations with PopEntry::can_pop_notifier through this route’s pop_disposition method.

Source

fn unregister_pop_entry( self: Handle<Self>, app: &mut App, pop_entry: Rc<dyn PopEntry>, )

Unregisters a PopEntry in the route’s widget subtree.

Source

fn maybe_dispatch_navigation_notification(self: Handle<Self>, app: &mut App)

Dart’s _maybeDispatchNavigationNotification.

Source

fn did_change_previous( self: Handle<Self>, app: &mut App, previous_route: Option<AnyRoute>, )

Dart’s ModalRoute.didChangePrevious.

Source

fn did_change_next( self: Handle<Self>, app: &mut App, next_route: Option<AnyRoute>, )

Dart’s ModalRoute.didChangeNext.

Source

fn did_pop_next(self: Handle<Self>, app: &mut App, next_route: AnyRoute)

Dart’s ModalRoute.didPopNext.

Source

fn update_received_transition( self: Handle<Self>, app: &mut App, next_route: Option<AnyRoute>, )

The nextRoute is ModalRoute && canTransitionTo(nextRoute) && … branch both did_change_next and did_pop_next run.

Source

fn changed_internal_state(self: Handle<Self>, app: &mut App)

Dart’s ModalRoute.changedInternalState.

Source

fn changed_external_state(self: Handle<Self>, app: &mut App)

Dart’s ModalRoute.changedExternalState.

Source

fn can_pop(self: Handle<Self>, app: &mut App) -> bool

Whether this route can be popped.

A route can be popped if there is at least one active route below it, or if will_handle_pop_internally returns true.

Source

fn implies_app_bar_dismissal(self: Handle<Self>, app: &App) -> bool

Whether an app bar in the route should automatically add a back button or close button.

This returns true if there is at least one active route below it, or there is at least one LocalHistoryEntry with implies_app_bar_dismissal set to true.

Source

fn fullscreen_dialog(self: Handle<Self>, app: &App) -> bool

Whether this route is a full-screen dialog.

Source

fn build_modal_barrier_entry( self: Handle<Self>, app: &mut App, context: BuildContext, ) -> WidgetRef

Dart’s _buildModalBarrier.

Source

fn build_modal_barrier( self: Handle<Self>, app: &mut App, context: BuildContext, ) -> WidgetRef

Builds 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, and reach this body through ModalRouteBase::build_modal_barrier.

Source

fn build_modal_scope( self: Handle<Self>, app: &mut App, context: BuildContext, ) -> WidgetRef

Dart’s _buildModalScope: the part of the modal scope that does not change from frame to frame, cached so that the amount of building is minimized.

Source

fn create_overlay_entries( self: Handle<Self>, app: &mut App, ) -> Vec<Ref<OverlayEntry>>

Dart’s ModalRoute.createOverlayEntries.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§