首页 > 解决方案 > A non-null String must be provided to a Text widget

问题描述

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: () {})
          ],
        ),

标签: stringflutterdartflutter-layoutflutter-widget

解决方案


你应该检查 null 安全

Text(cart_prod_qty??'default value'),

推荐阅读