amountUnderPaymentMethod method
Implementation
Widget amountUnderPaymentMethod(List data, String key) {
double totalAmount = 0;
data.forEach((element) {
String amountString = element['amount']
.toString()
.replaceAll(',', '')
.replaceAll('Ksh', '');
// Check if the amount string is a valid double
if (double.tryParse(amountString) != null) {
// If it's a valid double, parse and add it to totalAmount
totalAmount += double.parse(amountString);
} else {
// If it's not a valid double, you can handle this case as needed
}
});
return TextWidget(
text:
"KES ${Get.find<GraphsController>().format.format(double.parse(totalAmount.toStringAsFixed(2).toString()))}",
// Format totalAmount to two decimal places
color: greenIntColor,
fontSize: 14,
fontWeight: FontWeight.w700,
textAlign: TextAlign.center,
);
}