flutter路由

1、最基本的路由跳转

//先引入需要跳转的组件
Navigator.of(context).push(
    MaterialPageRoute(
        build: (context)=>跳转到的组件;
    )
);

2,跳转传值

//formPage页
.
.
string title;
FormPage({this.title="表单页"});
Widget build(BuildContext context){
    return Scaffold(
        appBar:AppBar(
            title: Text(this.title),
        )
    )
}
//other页
.
.
 body:container(
            child:RaisedButton(
                child: text('mmm'),
                onpressed:(){
                    Navigator.of(context).push(
                        MaterialPageRoute(
                            builder:(context) => FormPage(title: '我是表单页')
                        )
                    )
                }
        )
 )

猜你喜欢

转载自www.cnblogs.com/xhrr/p/11443755.html