Flutter 路由跳转

发布时间 2023-12-18 16:32:53作者: angelwgh
//普通跳转
   Navigator.pushNamed(context, '/search');
//返回上一页
  Navigator.of(context).pop();
// 替换路由(重定向)
  Navigator.of(context).pushReplacementNamed('/category');
// 返回根路由(清空当前路由,并跳转到指定页面)
  Navigator.of(context).pushAndRemoveUntil(
    MaterialPageRoute(builder: (context) {
    return const Home();
  }), (route) => false);