Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Height of Scaffold's Bottom Navigation Bar in Flutter

Tags:

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?

like image 447
yousef sidani Avatar asked Dec 02 '18 15:12

yousef sidani


People also ask

How do you customize the bottom navigation bar in flutter?

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.


1 Answers

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.

like image 190
wowlol Avatar answered Sep 20 '22 19:09

wowlol