我想在我的 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/