I have a ExpansionTile widget and I want to calculate a value inside it and pass that variable (total) to the trailing property. How is it possible to achieve this?
for (var name in widget.namesList)
Padding(
padding: const EdgeInsets.all(8.0),
child: Material(
child: Card(
shape: RoundedRectangleBorder(
),
ExpansionTile(
title: Text(
name,
),
children: <Widget>[
for (var food in widget.foodDetails)
if (food.foodEatenBy.contains(name))
Padding(
padding: const EdgeInsets.all(3.0),
child: Text(
(double.parse(food.foodTotalAfterTax
.toString()
.substring(
1,
food.foodTotalAfterTax
.toString()
.length -
1)) /
food.foodEatenBy.length)
.toStringAsFixed(2), //keep adding this value to a variable total
),
),
],
trailing: total,
),
),
),
),
),