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
This looks like a problem with null
value. In Text(cart_prod_qty)
, you're providing null to a Text widget, which is not allowed. in Text widget The data parameter must not be null.
The solution Do not pass null
to Text
widgets. To avoid it set a default value or Check the values you are receiving is not null. when calling the Text()
widgets
You can assign a default value and could change that to follow:
Text(cart_prod_qty ?? 'default value').
If you have a dart model or collection type then check null value and pass a default value like this
ListTile(
title: Text(User[‘user_name’] ?? 'default'),
subtitle: Text(User[‘user’_info] ?? 'default'),
);