flutter学习Flutter

flutter appBar 去掉返回按钮

2019-03-21  本文已影响0人  kot_flu

appBar经常需要定制,很多时候可能是不需要返回按钮的,那么就需要去掉了

带返回按钮.jpg 不带返回按钮.jpg

下面就介绍几个办法来去掉这个返回按钮

  1. 通过设置属性 automaticallyImplyLeading: false,
    具体代码:
 Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
        appBar: new AppBar(
      centerTitle: true,
      backgroundColor: Colors.black,
      title: TextFileWidget(),
      automaticallyImplyLeading: false, //设置没有返回按钮

2.可以设置跳转的方式

//                Navigator.pushReplacementNamed(context,"/search");
//                Navigator.pushNamedAndRemoveUntil(context,"/search",(_)=>false);
//              Navigator.pushAndRemoveUntil(context, new MaterialPageRoute(builder: (context) => new Search()), (_)=>false);

这几种跳转方式,都是返回就直接关掉了应用了,也就是不希望用户go back的操作,慎用

上一篇 下一篇

猜你喜欢

热点阅读