String getTotalPayment({ List<List<double?>>? totalPrice}) {
totalPrice = [[132], [143], [110]];
if (totalPrice.isEmpty) {
return "0";
} else {
double sum = 0;
for (var i = 0; i < totalPrice.length; i++) {
sum += totalPrice[i] as double;
}
// totalPrice.reduce((value, current) => value + current);
return sum.toString();
}
}
I get this error:
type 'List<double?>' is not a subtype of type 'double' in type cast!!
uTotalPayment: pending.data !=null ?
getTotalPayment(totalPrice: pending.data!.map((e) => e.invoices!.map((e) => e.total!.toDouble()).toList()