gpt4 book ai didi

flutter - 如何在 Flutter 中向 LinearProgressIndicator 添加边界/角半径?

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

我正在尝试向 Flutter 中的 LinearProgressIndicator 添加边框半径。

当我在下面的代码中用另一个小部件(例如 Text)替换 LinearProgressIndicator 时,它按预期工作。

Container(
decoration: new BoxDecoration(
borderRadius:
new BorderRadius.all(const Radius.circular(20.0))),
child: LinearProgressIndicator(
value: _time,
),
)

a busy cat

最佳答案

1) 使用微件

 Container(
margin: EdgeInsets.symmetric(vertical: 20),
width: 300,
height: 20,
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(10)),
child: LinearProgressIndicator(
value: 0.7,
valueColor: AlwaysStoppedAnimation<Color>(Color(0xff00ff00)),
backgroundColor: Color(0xffD6D6D6),
),
),
)

enter image description here

2) 使用依赖

不同类型指标列表 https://pub.dev/packages/percent_indicator

试试这个模板代码

        child:  Padding(
padding: EdgeInsets.all(15.0),
child: LinearPercentIndicator(
width: MediaQuery.of(context).size.width - 50,
animation: true,
lineHeight: 20.0,
animationDuration: 2000,
percent: 0.9,
linearStrokeCap: LinearStrokeCap.roundAll,
progressColor: Colors.greenAccent,
),
)

enter image description here

关于flutter - 如何在 Flutter 中向 LinearProgressIndicator 添加边界/角半径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57534160/

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