pushClearTop static method

Future pushClearTop(
  1. BuildContext context,
  2. Widget page, {
  3. String? name,
  4. Object? arguments,
  5. bool noAnimation = true,
  6. bool hide = true,
})

跳转到起始页并关闭所有页面

Implementation

static Future<dynamic> pushClearTop(BuildContext context, Widget page,
    {String? name,
    Object? arguments,
    bool noAnimation = true,
    bool hide = true}) {
  hideKeyboard(context, hide: hide);
  return Navigator.pushAndRemoveUntil(
    context,
    noAnimation
        ? NoAnimRouter(page, name: name, arguments: arguments)
        : MaterialPageRoute(
            settings: RouteSettings(name: name, arguments: arguments),
            builder: (_) => page),
    (Route<dynamic> route) => false,
  );
}