我想知道,如果有人知道一种方法,以删除显示在appBar在颤振应用程序,当你使用Navigator。pushNamed转到另一个页面。我不希望它出现在这个结果页面上的原因是它来自导航,我希望用户使用注销按钮,这样会话就可以重新开始。


当前回答

如果导航到另一个页面。可以使用Navigator.pushReplacement()。如果你从登录导航到主屏幕,它可以被使用。或者你可以用。 AppBar (automaticallyImplyLeading: false)

其他回答

  appBar: new AppBar(title: new Text("SmartDocs SPAY"),backgroundColor: Colors.blueAccent, automaticallyImplyLeading:false,
        leading: new Container(),
      ),

工作正常

//如果你想隐藏后退按钮使用下面的代码

class SecondScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
  appBar: AppBar(
    title: Text('Remove Back Button'),
    
    //hide back button
    automaticallyImplyLeading: false,
   ),
  body: Center(
    child: Container(),
  ),
);
}
}

//如果你想隐藏后退按钮并停止弹出动作,使用下面的代码

class SecondScreen extends StatelessWidget {

@override
Widget build(BuildContext context) {
 return new WillPopScope(

  onWillPop: () async => false,
  child: Scaffold(
    appBar: AppBar(
      title: Text("Second Screen"),
      //For hide back button
      automaticallyImplyLeading: false,
    ),
    body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            RaisedButton(
              child: Text('Back'),
              onPressed: () {
                Navigator.pop(context);
              },
            ),
          ],
        )
    ),
  ),
);
 }

只需在AppBar()中使用automcallyimplyleading即可

appBar: AppBaar(
  automaticallyImplyLeading: false,
)

如果导航到另一个页面。可以使用Navigator.pushReplacement()。如果你从登录导航到主屏幕,它可以被使用。或者你可以用。 AppBar (automaticallyImplyLeading: false)

AppBar小部件有一个名为automcallyimplyleading的属性。默认情况下,它的值为true。如果你不想让颤振自动构建后退按钮,然后只需使属性为假。

appBar: AppBar(
  title: Text("YOUR_APPBAR_TITLE"), 
  automaticallyImplyLeading: false,
),

添加自定义后退按钮

appBar: AppBar(
  title: Text("YOUR_APPBAR_TITLE"), 
  automaticallyImplyLeading: false,
  leading: YOUR_CUSTOM_WIDGET(),
),