07-21-2023, 08:57 PM
I am trying to get a container to be exactly half the screen height[after considering the AppBar height] and half the screen width.
This is what I came up with...
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Flexible(
child: Container(
width: MediaQuery.of(context).size.width / 2,
color: Colors.red,
),
),
Flexible(
flex: 1,
child: Container(),
)
],
),
);
}
}
Is there a better way?
[![current layout][1]][1]
[1]:
This is what I came up with...
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Flexible(
child: Container(
width: MediaQuery.of(context).size.width / 2,
color: Colors.red,
),
),
Flexible(
flex: 1,
child: Container(),
)
],
),
);
}
}
Is there a better way?
[![current layout][1]][1]
[1]: