问题描述
Provider.of<Products>(context,listen: false)
.addProducts(_editedProduct)
.catchError((error) {
return showDialog<Null>(
context: context,builder: (ctx) {
return AlertDialog(
title: Text(
'An error occurred',),content: Text('SomethingWent Wrong'),actions: [
FlatButton(
child: Row(
children: [
Icon(Icons.close),Text('Close'),],onPressed: () {
Navigator.of(context).pop();
},)
],);
},);
}).then((value) {
setState(() {
_isLoading = false;
});
Navigator.of(context).pop();
});
我能够显示警报对话框,但无法显示标题。我找不到原因。 一切正常,除了标题未显示。
解决方法
return AlertDialog(
title: Text('AlertDialog Title'),content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text('This is a demo alert dialog.'),Text('Would you like to approve of this message?'),],),actions: <Widget>[
FlatButton(
child: Text('Approve'),onPressed: () {
Navigator.of(context).pop();
},
尝试一下,看看是否可行。