Хорошо, поэтому я новичок в флаттере, но я пытаюсь получить и отобразить элементы в списке, используя 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
- это виджет, который должен отображать один элемент в список moneyTransactions