2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > flutter 隐藏返回按钮 自定义返回按钮

flutter 隐藏返回按钮 自定义返回按钮

时间:2024-05-06 18:35:25

相关推荐

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"),

隐藏返回按钮

// methodsvoid 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);

/a/51508446

/a/46713257

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。