Flutter - Creating tables dynamically
First fetch List of Records
List<PriceDetailsView> priceDetailsList = MockDataSource.getPriceDetailsDataList();
Now create an empty list of table rows :
List<TableRow> priceTableRows = [];
Add details from the fetched list to this row list:
for(PriceDetailsView priceDetalis in priceDetailsList){ priceTableRows.add(TableRow(children: [Text(priceDetalis.priceType), Text(priceDetalis.priceValue)])); }
Now create your table with this list of row :
Table priceTable = Table(children: priceTableRows);
It's pretty easy, actually! All you have to do is, make a list of TableRows, and put that in the children parameter of your table. For example
List<TableRow> tableRows = [];// dynamically make TableRows and add them to the list
And then you can just do this:
Table( children: tableRows, // other stuff)