flutter - 如何仅在 TableWidget 的 colmun 中设置 backgroundColor?
问题描述
我只想在表格的左侧添加颜色,但我尝试了各种方法,但它们都不起作用,如下图所示。我怎样才能做到这一点?
final informations = [
{"title": "e-mail", "text": "xxxxxx@xxxx"},
{"title": "phone number", "text": "111111111111"},
{"title": "other", "text": "nothingnothingnothingnothingnothingnothingnothingnothingnothingnothingnothing"}
];
List<TableRow> getWidgets(List<Map<String, String>> infos) {
final List<TableRow> listed = <TableRow>[];
for (int i = 0; i < infos.length; i++) {
listed.add(TableRow(children: [
Container(color: Colors.blue.shade400,child: Text(infos[i]["title"])),
Container(child: Text(infos[i]["text"]),)
]));
}
return listed;
}
谢谢。
解决方案
你可以尝试这样的事情:
final List<Map<String, String>> informations = [
{"title": "e-mail", "text": "xxxxxx@xxxx"},
{"title": "phone number", "text": "111111111111"},
{
"title": "other",
"text":
"nothingnothingnothingnothingnothingnothingnothingnothingnothingnothingnothing"
}
];
List<TableRow> getWidgets(List<Map<String, String>> infos) {
final List<TableRow> listed = <TableRow>[];
for (int i = 0; i < infos.length; i++) {
listed.add(TableRow(children: [
TableCell(
verticalAlignment: TableCellVerticalAlignment.fill,
child: Container(
color: Colors.blue.shade400, child: Text(infos[i]["title"]))),
TableCell(
child: Container(child: Text(infos[i]["text"])),
)
]));
}
return listed;
}
推荐阅读
- floating-point - 单精度浮点数的精度(IEEE 754 标准)
- javascript - 捕捉到刻度并在自定义范围滑块中移动刻度位置
- javascript - 使用普通 javascript 画布在 2d 体素世界中获得更好的性能?
- reactjs - 基于 props 的动画条件渲染与 react-spring
- c++ - gRPC 发送超大消息
- python - 无法安装pypi包-OsError
- python - 计算 pandas 中的重复行和一个非常大的 csv 文件
- django - AttributeError:“_EnumDict”对象没有属性“_cls_name”
- angular - 从同一集群中的 shibboleth kubernetes pod 访问后端 kubernetes 应用程序时出现 CORS 错误
- html - Rvest 找不到 eq 标签