[英]is there a way to implement a target line in a horizontal bar chart in flutter?
I want to do like this chart enter image description here我想像这张图表一样在此处输入图片描述
I have searched in different packages trying to find a bar chart with properties that support this but I didn't find yet.我在不同的包中进行了搜索,试图找到具有支持此属性的条形图,但我还没有找到。
Try to play with Stack widget尝试使用 Stack 小部件
class BCw extends StatefulWidget {
const BCw({super.key});
@override
State<BCw> createState() => _BCwState();
}
class _BCwState extends State<BCw> {
double value = .3;
@override
Widget build(BuildContext context) {
return Scaffold(
body: LayoutBuilder(
builder: (p0, constraints) => Column(
children: [
Slider(
value: value,
onChanged: (v) {
setState(() {
value = v;
});
},
),
SizedBox(
height: 64,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Stack(
children: [
Positioned(
top: 8,
bottom: 8,
left: 0,
right: constraints.maxWidth / 2,
child: Container(
height: 40,
color: Colors.green,
),
),
Positioned(
top: 0,
bottom: 0,
left: constraints.maxWidth * value,
child: VerticalDivider(
color: Colors.grey,
thickness: 5,
),
)
],
),
),
Text("${value.toStringAsFixed(2)}"),
],
),
),
],
),
),
);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.