gpt4 book ai didi

class - Flutter appBar Backbutton 没有出现

转载 作者:IT王子 更新时间:2023-10-29 06:35:29 25 4
gpt4 key购买 nike

我已成功导航到新文件中的一个类,但现在我的 appBar 上没有后退按钮。这是我在 main.dart 中的导航...

new RaisedButton(
onPressed: () {
Navigator.pushNamed(context, '/searchpage');
},

这是我的 SearchPage appBar..

class SearchPageState extends State<SearchPage> {
@override
Widget build(BuildContext context) {
return new MaterialApp(
routes: <String, WidgetBuilder>{
'/loginpage': (BuildContext context) => new Login.LoginPage(),
'/mainpage': (BuildContext context) => new Main.MyApp(),
},
home: new Scaffold(
appBar: new AppBar(
title: new Text(
"Search",
style: new TextStyle(fontWeight: FontWeight.bold),
),
),

最佳答案

您的应用程序的根目录中应该只有一个 MaterialApp。每个 MaterialApp 创建自己的 Navigator,导航堆栈上存在多个路由是导致隐式后退按钮出现在 leading 中的原因AppBar 的插槽。

关于class - Flutter appBar Backbutton 没有出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45970979/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com