如何在颤动中调整芯片大小 [英] How to adjust the size of a chip in flutter
本文介绍了如何在颤动中调整芯片大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在视图中显示大量筹码,并在其中显示文本。由于数量很多,我想将芯片的尺寸减小到最小。特别是芯片的高度。
I want to display a large number of chips in my view with text inside it. Since the count is big I want to decrease the size of the chip to the minimum. Specifically the height of the chip. How can this be done?
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);
}
我给了填充:new EdgeInsets.fromLTRB (5.0,0.0,5.0,0.0),
,但不会减小其默认大小。是否可以将具有所需尺寸的自定义形状赋予芯片?如果是这样,怎么办?
I've given padding: new EdgeInsets.fromLTRB(5.0, 0.0, 5.0, 0.0),
for the chip but its default size is not reduced. Can a custom shape with required size be given to a chip? If so, How can it be done? Thanks in advance folks.
推荐答案
您可以将芯片包装在 Transform
小部件并按如下所示缩放它:
You can wrap the chip in a Transform
widget and scale it as follows:
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),
),
),
这篇关于如何在颤动中调整芯片大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文