Title is not displayed in AlertDialog Widget Flutter

723 views Asked by At
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();
  });

I was able to display an alert dialogue but I coundn't show the title. I am unable to find the reason. Everything is working fine except the title is not displaying.

Alert Dialog Screenshot

2

There are 2 answers

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

Try this and see if it works.

0
Talya Sterman On

Happened to me too. Give the text a color, I think the default is white so you can't see it.