带有返回数据的Flutter Back按钮
问题内容:
我有一个带有两个按钮的界面,这些按钮会弹出并返回true或false,如下所示:
onPressed: () => Navigator.pop(context, false)
我需要调整应用栏中的后退按钮,因此它会弹出并返回false。有没有办法做到这一点?
问题答案:
这可能对您有帮助并为您工作
第一屏
void goToSecondScreen()async {
var result = await Navigator.push(_context, new MaterialPageRoute(
builder: (BuildContext context) => new SecondScreen(context),
fullscreenDialog: true,)
);
Scaffold.of(_context).showSnackBar(SnackBar(content: Text("$result"),duration: Duration(seconds: 3),));
}
第二屏
Navigator.pop(context, "Hello world");