Ad

OverflowBar's Children Must Not Contain Any Null Values, But A Null Value Was Found At Index 1

- 1 answer

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

Answer

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

Ad
source: stackoverflow.com
Ad