Context:我正在尝试使用Flutter制作Web应用-一切都在Chrome中完成
问题:我有一个来自[[charts_flutter库的图表,当在Column中时,它会显示OK。问题是我希望能够在图表下方滚动并添加更多内容。当我尝试将列更改为ListView时,它会溢出(似乎Chart试图尽可能大,并且ListView具有无限的高度)。我不确定如何解决此问题。
当前代码:只是脚手架,因为这就是我认为很重要的]]
Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: ListView(
children: <Widget>[
Row(
children: <Widget>[
FlatButton(onPressed: (){
print("flat button pressed");
}, child: Text("Flat Button 1")),
FlatButton(onPressed: (){
print("flat button pressed");
}, child: Text("Flat Button 2")),
FlatButton(onPressed: (){
print("flat button pressed");
}, child: Text("Flat Button 3")),
],
mainAxisAlignment: MainAxisAlignment.center,
),
Flexible(child: GroupedStackedBarChart.withRandomData()),
],
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
[上下文:我正在尝试使用Flutter创建Web应用程序-一切都在Chrome中解决。问题:我有一个来自Charts_flutter库的图表,当它位于Column中时,呈现为OK。问题是我...
Listview
包装了Expanded
,并用Column
扩展了小部件,如下所示:Flexible
使图表填充父级的高度,这是无限的。尝试将其包装在Column
中以提供预先计算的尺寸。