A non-null String must be provided to a Text widget

Mm Victory picture Mm Victory · May 29, 2019 · Viewed 41.9k times · Source

I'm trying to add the option for the quantity to be adjusted but I get an error saying "A non-null String must be provided to a Text widget" How do I provide this, to this code? img

 trailing: Container(
        height: 60,
        width: 60,
        padding: EdgeInsets.only(left: 10),
        child: Column(
          children: <Widget>[
            new GestureDetector(child: Icon(Icons.arrow_drop_up), onTap: () {}),
            new Text(cart_prod_qty),
            new GestureDetector(child: Icon(Icons.arrow_drop_down), onTap: () {})
          ],
        ),

Answer

Nikhil Vadoliya picture Nikhil Vadoliya · May 29, 2019

You should check null safe

Text(cart_prod_qty??'default value'),