How can I get the height
of the BottomNavigationBar
of a Scaffold
in Flutter? I know there is MediaQuery.of(context).size
to get a screen size. Is there a similar method for BottomNavigationBar
?
Now let's create our bottom navigation bar. In the HomePage class let's define the bottomNavigationBar attribute and assign a Container to it. Give it a height of 60 with some BoxDecoration (Pixels) add a Row as the child of the Container. Set the main axis alignment to space around.
Container(
width: MediaQuery.of(context).size.width,
height: kBottomNavigationBarHeight,
child: Scaffold(
backgroundColor: Colors.transparent,
body: null,
bottomNavigationBar: BottomNavigationBar()
)
)
This will create a Scaffold with enough room only for the BottomNavigationBar widget.
kBottomNavigationBarHeight is a constant, and can be found in the constants.dart file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With