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...
<
You can deduct AppBar
's height to configure Container
size.
@override
Widget build(BuildContext context) {
var appBar = AppBar();
return Scaffold(
appBar: appBar,
body: Align(
alignment: Alignment.topCenter,
child: Container(
height: (MediaQuery.of(context).size.height - appBar.preferredSize.height) / 2,
width: MediaQuery.of(context).size.width / 2,
color: Colors.red,
),
),
);
}