flutter - 在扩展小部件内使用颤振图表小部件
问题描述
这是我想要制作的 UI 的表示(请原谅粗略):
我打算将欢迎回复消息、最新阅读消息和图表都放在一个列中,并扩大图表以填满整个屏幕。这是我的组件树和到目前为止的构建方法:
@override
Widget build(BuildContext context) {
return Container(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: _data == null || _data.length == 0
? Center(
child: Text(
'No data, add data to get started',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
)
: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Welcome Back",
style: TextStyle(fontSize: 36, fontWeight: FontWeight.bold),
),
SizedBox(
height: 20,
),
Text(
"Your latest reading was ${_data.last.systolic}/${_data.last.diastolic}.",
style: TextStyle(fontSize: 16),
),
BPLineChart(data: _data),
],
),
),
);
但是,如果我用扩展的小部件包装 BPLineChart,我会在控制台中收到此 ui 错误
I/flutter (11080): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (11080): The following assertion was thrown during performLayout():
I/flutter (11080): RenderCustomMultiChildLayoutBox object was given an infinite size during layout.
I/flutter (11080): This probably means that it is a render object that tries to be as big as possible, but it was put
I/flutter (11080): inside another render object that allows its children to pick their own size.
这在ui中:
有没有办法用扩展的小部件包装颤振图表小部件?
解决方案
推荐阅读
- arrays - Swift - How to add string array to my listview in swiftUI
- matlab - 如何在给定另一个数组的情况下创建 Matlab 数组
- wordpress - 用树枝将项目分成两列
- ssh - 我可以在 Cloud Run 实例中使用 ssh 客户端连接到内部网络吗
- php - 如何回显目录中的前 N 个文件
- c# - is there any way to pass class object generically to the method
- selenium - 使用 docker-compose 无法访问站点 zalenium
- cgeventtap - 在`NSEventTap`中返回我自己创建的`CGEvent`
- r - 如何创建具有特定重复模式的字母/数字列表?
- javascript - Firebase Web 身份验证不起作用 - 仅针对键入错误的电子邮件返回错误