Ok so I am kind of new to flutter, but I trying to fetch and display items in a list using map.
class TransactionTable extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return TransactionTableState();
}
}
class TransactionTableState extends State {
final List moneyTransactions = [
new MoneyTransactionModel(
id: "1",
productId: "lime",
entryType: "sold",
quantity: "60kg",
unitPrice: "240rwf/kg",
paidBy: "mtn",
createdAt: "2020-04-20T00:15:08.932Z"),
new MoneyTransactionModel(
id: "2",
productId: "lime",
entryType: "sold",
quantity: "60kg",
unitPrice: "240rwf/kg",
paidBy: "mtn",
createdAt: "2020-04-20T00:15:08.932Z"),
new MoneyTransactionModel(
id: "3",
productId: "lime",
entryType: "sold",
quantity: "60kg",
unitPrice: "240rwf/kg",
paidBy: "mtn",
createdAt: "2020-04-20T00:15:08.932Z"),
new MoneyTransactionModel(
id: "4",
productId: "lime",
entryType: "sold",
quantity: "60kg",
unitPrice: "240rwf/kg",
paidBy: "mtn",
createdAt: "2020-04-20T00:15:08.932Z"),
];
Widget build(BuildContext context) {
// return
return Column(
children: <Widget>[
moneyTransactions.map((e) => MyListTile()); // i need to the the loop here
],
);
}
}
MyListTile is a widget supposed to display one item in the moneyTransactions list