OverflowBar's children must not contain any null values, but a null value was found at index 1

Issue

hi I work to update mobile application build with flutter .but when I run this app I get this error
OverflowBar’s children must not contain any null values, but a null value was found at index 1

final rep = await showDialog(
           context: context,
           builder: (BuildContext context) {
             return AlertDialog(
               title: Text("Entrez votre constat : "),
               content: new TextField(
                 keyboardType: TextInputType.multiline,
                 maxLines: 5,
                 controller: _constate,
               ),
               actions: <Widget>[
                 FlatButton(
                   child: Text("Enregistrer"),
                   onPressed: () {
                     Navigator.pop(context, _constate.text);
                   },
                 ),
                 c!=null?FlatButton(
                   child: Text("Supprimer"),
                   onPressed: () {
                     _deleteConstat(c, q);
                     Navigator.pop(context, null);
                   },
                 ):null,
                 FlatButton(
                   child: Text("Anuller"),
                   onPressed: () {
                     Navigator.pop(context, null);
                   },
                 ),
               ],
               elevation: 23,
             );
           }); ```

Solution

This code is causing the error

  c!=null?FlatButton(
                   child: Text("Supprimer"),
                   onPressed: () {
                     _deleteConstat(c, q);
                     Navigator.pop(context, null);
                   },
                 ):null,

Prefer a SizedBox for whitespace instead of null

Answered By – esentis

Answer Checked By – Marie Seifert (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *