dart - 如何在 flutter 中调整芯片的大小

我想在我的 View 中显示大量芯片,其中包含文本。由于计数很大,我想将芯片的尺寸减小到最小。特别是芯片的高度。如何做到这一点?

for (EPDiaryTarget target in widget.item.targetList) {
    Chip chip = new Chip(
      label: new Text(
        target.name,
        overflow: TextOverflow.ellipsis,
        style: new TextStyle(color: Colors.white),
      ),
      backgroundColor: const Color(0xFFa3bdc4),
    );
    studentsChips.add(chip);
  }

我已经为芯片提供了 padding: new EdgeInsets.fromLTRB(5.0, 0.0, 5.0, 0.0), 但它的默认大小没有减小。可以为芯片提供具有所需尺寸的自定义形状吗?如果是这样,怎么做?在此先感谢各位。

最佳答案

您可以将芯片包装在 Transform 小部件中并按如下方式对其进行缩放:

    Transform(
      transform: new Matrix4.identity()..scale(0.8),
      child: new Chip(
        label: new Text(
          "Chip",
          overflow: TextOverflow.ellipsis,
          style: new TextStyle(color: Colors.white),
        ),
        backgroundColor: const Color(0xFFa3bdc4),
      ),
    ),

https://stackoverflow.com/questions/51440984/

相关文章:

android - 如何在 Flutter 中动态附加到 Column 小部件的子级

dart - flutter 相机插件

dart - Flutter - 显示来自相机的本地镜像

dart - NumberFormat 未找到 flutter

flutter - 如何在 Flutter 中实现交错 GridView ?

dart - API调用后有状态小部件的 flutter 计时问题

ios - 关闭 Cupertino 对话 Action Flutter

dart - 根据当前查看的页面更改 AppBar 的颜色和文本

flutter - Flutter 中按钮中的自定义图像

email - 使用 Flutter 的电子邮件进行 Firebase 身份验证