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

前端 未结 9 1675
醉酒成梦
醉酒成梦 2021-02-13 20:15

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 co

9条回答
  •  醉酒成梦
    2021-02-13 21:02

    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'),
    

提交回复
热议问题