[英]Flutter single `DataCell` color
我正在嘗試做類似於 Excel/Google Sheets/etc 可以做的事情,並將背景顏色添加到我的DataTable
上的一個DataCell
中。 我只能找到一個參考來設置整個DataRow
,而不僅僅是一個單元格。 有誰知道怎么做?
API 參考:
到目前為止我已經嘗試過:
DataCell(
FittedBox(
child: test
? ColoredBox(
color: Colors.orange,
child: Center(
child: Text(variable),
),
)
: Center(
child: Text(variable),
),
),
),
我得到了什么:
目標:
我通過從小部件樹中刪除FittedBox
解決了這個問題。
DataCell(
test
? Padding(
padding: const EdgeInsets.symmetric(vertical: 5),
child: ColoredBox(
color: Colors.orange,
child: Center(
child: Text(variable, style: style),
),
),
)
: Center(
child: Text(variable, style: style),
),
),
最終結果:
PS:這里的Padding
只是為了讓顏色保持在VerticalDivider
縮進(在側面)內。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.