Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Flutter
  2. widgets.dart
  3. Navigator
  4. pushAndRemoveUntil<T extends Object?> static method
pushAndRemoveUntil
description

pushAndRemoveUntil<T extends Object?> static method

  1. @optionalTypeArgs
Future<T?>pushAndRemoveUntil<T extends Object?>(
  1. BuildContextcontext,
  2. Route<T>newRoute,
  3. RoutePredicatepredicate
)

Push the given route onto the navigator that most tightly encloses thegiven context, and then remove all the previous routes until thepredicate returns true.

The predicate may be applied to the same route more than once ifRoute.willHandlePopInternally is true.

To remove routes until a route with a certain name, use theRoutePredicate returned fromModalRoute.withName.

To remove all the routes below the pushed route, use aRoutePredicatethat always returns false (e.g.(Route<dynamic> route) => false).

The removed routes are removed without being completed, so this methoddoes not take a return value argument.

The newly pushed route and its preceding route are notified forRoute.didPush. After removal, the new route and its new preceding route,(the route below the bottommost removed route) are notified throughRoute.didChangeNext). If theNavigator has anyNavigator.observers,they will be notified as well (seeNavigatorObserver.didPush andNavigatorObserver.didRemove). The removed routes are disposed of andnotified, once the new route has finished animating. The futures that hadbeen returned from pushing those routes will complete.

Ongoing gestures within the current route are canceled when a new route ispushed.

TheT type argument is the type of the return value of the new route.

Returns aFuture that completes to theresult value passed topopwhen the pushed route is popped off the navigator.

Typical usage is as follows:
link
void _finishAccountCreation() {  Navigator.pushAndRemoveUntil<void>(    context,    MaterialPageRoute<void>(builder: (BuildContext context) => const MyHomePage()),    ModalRoute.withName('/'),  );}

See also:

Implementation

@optionalTypeArgsstatic Future<T?> pushAndRemoveUntil<T extends Object?>(  BuildContext context,  Route<T> newRoute,  RoutePredicate predicate,) {  return Navigator.of(context).pushAndRemoveUntil<T>(newRoute, predicate);}
  1. Flutter
  2. widgets
  3. Navigator
  4. pushAndRemoveUntil<T extends Object?> static method
Navigator class

[8]ページ先頭

©2009-2026 Movatter.jp