Flutter 路由

flutter的路由简单使用

跳转

 Navigator.of(context)
        .push(MaterialPageRoute(
            builder: (context) {
              return Test();
              // ignore: prefer_const_constructors
            },
            settings: const RouteSettings(arguments: "测试"),
            fullscreenDialog: true))
        .then((value) => print(value));

参数接收

 var title = ModalRoute.of(context)?.settings.arguments;

返回值

 Navigator.of(context).pop("返回");
 // 接收
 Navigator.of(context)
        .push(MaterialPageRoute(
            builder: (context) {
              return Test();
              // ignore: prefer_const_constructors
            },
            settings: const RouteSettings(arguments: "测试"),
            fullscreenDialog: true))
        .then((value) => print(value));

posted on 2022-10-27 23:49  快乐海盗  阅读(25)  评论(0编辑  收藏  举报