这是我想要制作的 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.
在用户界面中:
有没有办法用扩展的小部件包装颤振图表小部件?