maybeOf static method
Returns the height of the bottom navigation bar if it exists, otherwise returns null.
It supports BottomAppBar, NavigationBar, and BottomNavigationBar.
The Scaffold is resolved with ScaffoldFinder, so this also works when
context sits above the Scaffold it belongs to.
Example:
final bottomBarHeight = BottomBarHeight.maybeOf(context);
Implementation
static double? maybeOf(BuildContext context) =>
switch (ScaffoldFinder.maybeOf(context)?.widget.bottomNavigationBar) {
BottomAppBar _ => Theme.of(context).bottomAppBarTheme.height ?? 80,
NavigationBar _ => Theme.of(context).navigationBarTheme.height ?? 80,
BottomNavigationBar _ => kBottomNavigationBarHeight, // 58 actually
null => null,
_ => _fallbackHeight(context),
};