2017-08-30 51 views
0

我已成功導航到新文件中的類,但現在我沒有在我的appBar上獲得後退按鈕。下面是我的main.dart導航...Flutter appBar Backbutton does not appear

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

回答

2

您應該只有在你的應用程序的根目錄一個MaterialApp。每個MaterialApp創建它自己的Navigator,並且導航堆棧上存在多個路由是導致隱式後退按鈕出現在AppBarleading插槽中的原因。