body: Container(
padding: EdgeInsets.all(25),
child: Table(
border: TableBorder.all(),
columnWidths: {
0: FractionColumnWidth(0.14),
1: FractionColumnWidth(0.6),
2: FractionColumnWidth(0.3),
},
children: [
// here to add iconButton
buildRow(['No.','List of Books','Action'], isHeader: true),
buildRow(['1','Harry Potter Philosopher','Action']),
buildRow(['2','Sleeping Beauty','Action']),
buildRow(['3','Beauty and The Beast','Action']),
],
),
),
);
// here List<String>
TableRow buildRow(List<String> cells, {bool isHeader = false}) => TableRow(
children: cells.map((cell) {
final style = TextStyle(
fontWeight: isHeader? FontWeight.bold : FontWeight.normal,
fontSize: 18,
);
return Padding(
padding: const EdgeInsets.all(12),
child: Center(
child: Text(
(cell), //here error
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15,
),
),
),
);
}).toList(),
);
}
Here is i confused to declare icon button in the parameter buildRow cause it carry String but when i change to Widget it will appear the error at Text(cell). I want to add the iconButton in the third row of the table
Just declare List<Strings> cells
to List<Widgets> cells
like below code:
Use like this:
buildRow([Text('1'), IconButton(onPressed: (){}, icon: Icon(Icons.edit))], isHeader: true),
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.