zoukankan      html  css  js  c++  java
  • flutter 隐藏返回按钮 自定义返回按钮

    自定义返回按钮

    //改变颜色
    Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            leading: BackButton(
                color: Colors.black
            ),
    
    //改变颜色
      appBar: AppBar(
              iconTheme: IconThemeData(
                color: Colors.black, //change your color here
              ),
              title: Text("Sample"),
              centerTitle: true,
            ),
            body: Text("Sample body"),
          );
    //自定义返回按钮
         appBar: AppBar(
                   leading: new IconButton(
                   icon: new Icon(Icons.arrow_back, color: Colors.black),
                   onPressed: () => Navigator.of(context).pop(),
                  ), 
                  title: Text("Sample"),
                  centerTitle: true,
                ),
                body: Text("Sample body"),
    

    隐藏返回按钮

    // methods
    void changeScreen(BuildContext context, Widget widget){
      Navigator.push(context, MaterialPageRoute(builder: (context) => widget));
    }
    
    void changeScreenReplacement(BuildContext context, Widget widget){
      Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => widget));
    }
    
    
    Don't want to display that ugly back button ( :] ), and thus go for : AppBar(...,automaticallyImplyLeading: false,...);
    
    Don't want the user to go back - replacing current view - and thus go for: Navigator.pushReplacementNamed(## your routename here ##);
    
    Don't want the user to go back - replacing a certain view back in the stack - and thus use: Navigator.pushNamedAndRemoveUntil(## your routename here ##, f(Route<dynamic>)→bool); where f is a function returning truewhen meeting the last view you want to keep in the stack (right before the new one);
    
    Don't want the user to go back - EVER - emptying completely the navigator stack with: Navigator.pushNamedAndRemoveUntil(context, ## your routename here ##, (_) => false);
    

    https://stackoverflow.com/a/51508446
    https://stackoverflow.com/a/46713257

  • 相关阅读:
    echarts onClick执行之前都要取消绑定一次
    echarts 打包完之后体积太大解决方案。
    saga处理多个loading最少0.5s
    SVN命令详解
    netfilter/iptables原理
    交换两个变量的值,不使用第三个变量的四种法方
    linux常用命令整理
    vi技巧
    linux进程管理的常用命令
    gcc常用命令
  • 原文地址:https://www.cnblogs.com/qqcc1388/p/11543262.html
Copyright © 2011-2022 走看看