I am trying to create 3 sections in the body, but I would like that these 3 always cover the entire screen.
Container(
height: MediaQuery.of(context).size.height / 3,
width: double.infinity,
color: Colors.red,
),
MediaQuery is taking the entire screen as reference, that is why the last section overflow the same height as the appbar.
Is there any way to use the body as a reference for MediaQuery?
Try using Column
with children wrapped by Expanded
, each child will have the same size.
Column(
children: <Widget>[
Expanded(
child: Container(color: Colors.white),
),
Expanded(
child: Container(color: Colors.red),
),
Expanded(
child: Container(color: Colors.green),
),
],
);