The code below lays out a chart in which I\'d need to achieve for the chart to be expanded in both vertical (height) and horizontal (width) direction. The suggested method (e.g.
There is a better way than nesting Row
, Expanded
and Column
widget. You can use the Container
widget with Constraints
to BoxConstraints.expand()
.
Example Code:
Widget build(BuildContext context) {
return Container(
constraints: BoxConstraints.expand(),
child: FutureBuilder(
future: loadImage(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
switch(snapshot.connectionState) {
case ConnectionState.waiting :
return Center(child: Text("loading..."),);
default:
if (snapshot.hasError) {
return Center(child: Text("error: ${snapshot.error}"),);
} else {
return ImagePainter(image: snapshot.data);
}
}
},
),
);
}