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

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


You should check null safe

Text(cart_prod_qty??'default value'),


Just check for null and give a default

Text(cart_prod_qty!=null?cart_prod_qty:'default value'),

You can keep it empty if you wish

Text(cart_prod_qty!=null?cart_prod_qty:''),

Or else you can make text widget optional

cart_prod_qty!=null? Text(cart_prod_qty): Container()


The error itself shows what's wrong in the code, Text widget works only with string and for null they intentionally have thrown an exception. Check text.dart file implementation where they added throwing an exception.

assert(         data != null,         'A non-null String must be provided to a Text widget.',       ),

To solve above error you have to provide some default text.

new Text(cart_prod_qty!=null?cart_prod_qty:'Default Value'),