标题未显示在AlertDialog小部件Flutter中

问题描述

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

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

Alert Dialog Screenshot

解决方法

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

尝试一下,看看是否可行。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...