Vinodh
Vinodh

Reputation: 9

I am getting The operator '+' can't be unconditionally invoked because the receiver can be 'null'

DataCell( //ToDo: Calculate the total price for all items

Text(items.fold(0, (previousValue, element) => previousValue + element.itemPrice).toString() ), )

Upvotes: 0

Views: 85

Answers (1)

Josteve Adekanbi
Josteve Adekanbi

Reputation: 12693

Try specifying the datatype of previousValue

Like so:

 items.fold<double>(0, (previousValue, element) => previousValue + element)

Upvotes: 1

Related Questions