[英]How to deactivate or override the arrow back button in the appBar in flutter?
有沒有辦法在特定頁面上停用箭頭后退按鈕? 我建立了一個啟動畫面,每當啟動畫面導航到主頁時,在主頁應用程序欄中,返回的箭頭會顯示,如何停用它或清除返回上一頁的箭頭(歡迎屏幕)。
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () {return Future.value();
}, // async => true,
child: Scaffold(
appBar: AppBar(
title: Text("Application!"),
elevation: 20,
centerTitle: true,
actions: <Widget>[
IconButton(
icon: Icon(Icons.exit_to_app),
onPressed: () {
Navigator.pop(context);
},
),
PopupMenuButton(
icon: Icon(Icons.more_vert),
itemBuilder: (context) => [
PopupMenuItem(
child: Text("Home"),
),
PopupMenuItem(
child: Text("Hire"),
),
PopupMenuItem(
child: Text("Settings"),
),
PopupMenuItem(
child: Text("About"),
),
],
),
],
),
body: Center(
child: Container(
child: Text("Chech out my new Mobile Applications!")
),
),
),
);
}
將您的小部件包裝在WillPopScope
中,並在onWillPop
屬性中返回 false Future
。
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () => Future.value(false),
child: Scaffold(
appBar: AppBar(
title: const Text("Home Page"),
),
body: Center(
child: const Text("Home Page"),
),
),
);
}
您可能會發現您的答案已在此問題中得到解答
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.