0
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();
  });

我能够显示一个警告对话框,但我无法显示标题。我找不到原因。一切正常,除了标题没有显示。

警报对话框屏幕截图

4

2 回答 2

0
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();
        },
      ),
    ],

试试这个,看看它是否有效。

于 2020-09-27T06:42:57.267 回答
0

也发生在我身上。给文本一个颜色,我认为默认是白色的所以你看不到它。

于 2021-10-19T14:16:30.403 回答