I am using the Data table for showing the product lists and monthly revenue. I need to show annual revenue too, but I didn't get annual revenue from JSON. I only get monthly revenue and I need to multiply monthly revenue with 12 to get annual revenue. Here is my code for the data table
DataTable(
headingRowColor:
MaterialStateColor.resolveWith((states) => Color(0xFF00105C)),
columns: [
DataColumn(
label: Text("Product",
style: TextStyle(
fontSize: 12,
fontFamily: 'Roboto Bold',
color: Colors.white
),)),
// DataColumn(label: Text("Code")),
DataColumn(label: Text("Revenue(M)",
style: TextStyle(
fontFamily: 'Roboto Bold',
color: Colors.white
),
)
),
DataColumn(label: Text("Revenue(A)",
style: TextStyle(
fontSize: 12,
fontFamily: 'Roboto Bold',
color: Colors.white
),)),
],
rows: snapshot.data.map((e) => DataRow(
cells: [
DataCell(Text(e.product.productName,
style: TextStyle(
fontFamily: 'Roboto Regular',
color: Colors.black
),),),
// DataCell(Text(e.product.code)),
DataCell(Text(e.expectedRevenue.toString(),
style: TextStyle(
fontFamily: 'Roboto Regular',
color: Colors.black
),)),
DataCell(Text(e.expectedRevenue*12.toString(),
style: TextStyle(
fontFamily: 'Roboto Regular',
color: Colors.black
),)),
]
)).toList(),
),
expectedRevenue is a dynamic data type in JSON.
String id;
int leadProductId;
int leadId;
int productId;
dynamic expectedRevenue;
DateTime createdDate;
int createdBy;
int recordStatus;
dynamic lead;
Product product;
Here I got an error for the annual revenue data cell
type 'String' is not a subtype of type 'num' of 'other'
How to solve this issue? How to find the total value of Revenue(M) column data cells?