gpt4 book ai didi

flutter - 动态减小小部件的大小?

转载 作者:IT王子 更新时间:2023-10-29 07:21:07 24 4
gpt4 key购买 nike

我想制作一个看起来像这样的小部件 - 动态地:

enter image description here

这是我的尝试,鉴于我定义了较大圆圈的初始大小,我想动态减小大小:

Row _pagesIndcator(int length) {
List<Widget> points = <Widget>[];

for (var i = 0; i < length; i++) {
points.add(Padding(
padding: const EdgeInsets.only(right:2.0),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
height: 8,
width: 8,
),
));
}
return Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: points,
);
}

我试过这个:高度:8-i/1,

但我认为这不是正确的制作方法!

最佳答案

enter image description here

试一试,让我知道它是否有效,您可以根据需要使用这些值。

Row _pagesIndicator(int length) {
List<Widget> list = [];
list = List.generate(length, (i) {
return Container(
width: (length - i) * 10.0 + (i + 1) * 5,
height: (length - i) * 10.0 + (i + 1) * 5,
margin: EdgeInsets.symmetric(horizontal: 2),
decoration: BoxDecoration(shape: BoxShape.circle, color: Colors.black),
);
});

return Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: list,
);
}

关于flutter - 动态减小小部件的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55601224/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com