小编典典

如何在颤动中调整芯片大小

flutter

我想在视图中显示大量筹码,并在其中显示文本。由于数量很多,我想将芯片的尺寸减小到最小。特别是芯片的高度。如何才能做到这一点?

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),了该芯片,但是其默认大小并未减小。是否可以将具有所需尺寸的自定义形状赋予芯片?如果是这样,怎么办?在此先感谢大家。


阅读 223

收藏
2020-08-13

共1个答案

小编典典

您可以将芯片包装在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),
      ),
    ),
2020-08-13