pushNamedAndRemoveUntilRoot<T extends Object?> method

  1. @override
Future<T?> pushNamedAndRemoveUntilRoot<T extends Object?>(
  1. String routeName, {
  2. PageType pageType = PageType.flutter,
  3. bool isOpaque = true,
  4. bool animated = true,
  5. Map<String, dynamic>? arguments,
})
override

push 到指定页面,同时会清除从页面untilRouteName页面到指定routeName链路上的所有页面

@param routeName 要跳转的页面, @return T 泛型,用于指定返回类型

Implementation

@override
Future<T?> pushNamedAndRemoveUntilRoot<T extends Object?>(
  String routeName, {
  PageType pageType = PageType.flutter,
  bool isOpaque = true,
  bool animated = true,
  Map<String, dynamic>? arguments,
}) async {
  final result = await Navigator.of(rootContext).pushNamedAndRemoveUntil(
    routeName,
    (Route<dynamic> route) => route.isFirst,
    arguments: arguments,
  );
  if (result is! T?) {
    throw TypeError();
  }
  return result;
}