Search code examples
flutter

How can I remove the safe area padding of a BottomNavigationBar?


I am using a BottomNavigationBar and want to remove the safe area / viewInsets padding given to the bar. I am not referring to the typical answers to similar questions (setting font size to zero or hiding the labels). I am referring to the system padding added to keep the bar above system items like the iPhone X bottom bar, which seems to be the value of MediaQuery.of(context).viewInsets.bottom.

The reason is that in some situations I want to place something below the BottomNavigationBar, as odd as that sounds. In this case, the additional padding is still supplied and makes the bar have an awkward amount of padding below it before the bottom widget.

Is this even possible or would I need to construct a custom widget instead?


Solution

  • There does not appear to be a simple way to do this with BottomNavigationBar. There may be a complicated way with different sorts of clipping or custom paints, but ultimately decided it was easiest to create a custom navigation bar using a Container. It ended up being even simpler than an actual BottomNavigationBar in the end.