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

前端 未结 9 1656
醉酒成梦
醉酒成梦 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 20:44

    The value may be empty therefore youre getting a null error try this if its an optional field:

    new Text(cart_prod_qty == null ? '' : cart_prod_qty),
    
    0 讨论(0)
  • 2021-02-13 20:45

    just set Text widget value optional like

    Text(value ?? ""),
    
    0 讨论(0)
  • 2021-02-13 20:45

    I have faced that same problem.... I have resolved it by using a "new" keyword before Text...

    child: new Text(mydata[1]["2"][k]),

    0 讨论(0)
  • 2021-02-13 20:54

    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()
    
    0 讨论(0)
  • 2021-02-13 20:54

    I GOT SAME ERROR DUE TO THIS

    BEFORE:

    title:  Text(widget.title)
    

    AFTER:

    title:  Text('ram')
    
    

    THIS SOLVED MY ERROR

    To solve this error Add Double quote or single quote title: Text('ram')

    0 讨论(0)
  • 2021-02-13 20:56

    You should check null safe

    Text(cart_prod_qty??'default value'),
    
    0 讨论(0)
提交回复
热议问题