[英]how to create stacked bar/progress bar in flutter like this image
i dont know the name of this kind of visualization.我不知道这种可视化的名称。
Right now, I have 3 data here(sum,.net, cancel)现在,我这里有 3 个数据(总和,.net,取消)
The right side will display is cancel number, the left side display is.net number inside the stacked bar右边显示的是取消号,左边显示的是堆积条里面的.net号
with this bar, user will immediately know the sum number by .net + cancel)有了这个栏,用户将立即通过 .net + 取消知道总数)
is there some kind of package that can help me to display this bar有没有什么 package 可以帮我显示这个栏
Here is the widget builder that you want.这是您想要的小部件生成器。 Maybe the MediaQuery is a bad choice.也许 MediaQuery 是一个糟糕的选择。 But you can use any other sizing options.但您可以使用任何其他尺寸选项。
Widget _buildProgress(BuildContext context, int progress, int limit) {
return SizedBox(
height: 30,
width: double.infinity,
child: Stack(
children: <Widget>[
Positioned.fill(
child: Container(
decoration: const BoxDecoration(
color: Color(0xFF038918),
borderRadius: BorderRadius.all(Radius.circular(10)),
),
alignment: Alignment.centerRight,
padding: const EdgeInsets.only(right: 20),
child: Text(
'$limit',
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
),
Container(
width: MediaQuery.of(context).size.width / limit * progress,
decoration: const BoxDecoration(
color: Color(0xFFe40808),
borderRadius: BorderRadius.all(Radius.circular(10)),
),
alignment: Alignment.center,
child: Text(
'$progress',
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
],
),
);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.