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(),
);
}
这里是我混淆声明图标按钮参数buildRow的原因,它携带字符串,但当我改变为小部件,它会出现在文本(单元格)的错误。我想添加的iconButton在第三行的表格
1条答案
按热度按时间rqqzpn5f1#
只需将
List<Strings> cells
声明为List<Widgets> cells
,如下所示:这样使用: