簡體   English   中英

Flutter 單 `DataCell` 顏色

[英]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),
        ),
),

最終結果:

帶有 DataCell 的 DataTable 完全塗成橙色

PS:這里的Padding只是為了讓顏色保持在VerticalDivider縮進(在側面)內。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM