>2.12所以我正在进行更改,但我陷入了这个特定的错误,无法找到任何解决方案。non-nullable“空安全”问题后引起的 Future<bool?> _onBackPressed() async {
return showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Do you want to exit without saving changes?'),
content:
Text('Please press the SAVE button at the bottom of the page'),
actions: <Widget>[
TextButton(
child: Text('NO'),
onPressed: () {
Navigator.of(context).pop(false);
},
),
TextButton(
child: Text('YES'),
onPressed: () {
Navigator.of(context).pop(true);
Navigator.of(context).pop(true);
},
),
],
);
});
}
..
return WillPopScope(
onWillPop: () => _onBackPressed, // causing error
child: …Run Code Online (Sandbox Code Playgroud) 我正在尝试将文本添加到我的,floatingActionButton但我无法这样做。如何将文本添加到它没有找到任何方法。
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () async {
// when clicked on floating action button prompt to create user
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (BuildContext context) => CreateUser(),
),
);
},
),
);
}
Run Code Online (Sandbox Code Playgroud)