1

On the Samsung Galaxy S23 with android version 15 and One ui 7, there is a bottom system nav bar. Does anyone have any idea how to handle the nav height? is overflowing on the app.

I have trying SafeArea, my solution is

SizedBox(
        height: controller.isVisible.value ? 80 : 0,
        child: SafeArea(
          bottom: true,
          top: false,
          child: MyBottomNavBar(
            onItemSelected: controller.onMenuSelected,
            selectedIndex: controller.lastSelectedIndex.value,
          ),
        ),
      );

I'm also using this method to get the height of system nav bar,

/// Returns the height of the bottom system navigation bar (if present).
  static double getBottomSystemBarHeight(BuildContext context) {
    final viewPadding = MediaQuery.of(context).viewPadding;
    final viewInsets = MediaQuery.of(context).viewInsets;

    // Return bottom padding only if the keyboard is not open
    return viewInsets.bottom == 0 ? viewPadding.bottom : 0;
  }

I have used this returned value as bottom padding of MyBottomNavBar class

Container(
        padding: EdgeInsets.only(
          bottom: DeviceUtils.getBottomSystemBarHeight(context),
        ),
        decoration: BoxDecoration(
          boxShadow: [
            BoxShadow(
              color: Colors.grey.withValues(alpha: 0.5),
              spreadRadius: 3,
              blurRadius: 4,
              offset: Offset(0, 3),
            ),
          ],
        ),
        child: BottomNavigationBar(
          key: bottomNavKey,
          items: _navItemBuilder(navItems),
          elevation: 10,
          showSelectedLabels: true,
          showUnselectedLabels: true,
          selectedFontSize: 10,
          unselectedFontSize: 10,
          selectedLabelStyle: TextStyle(fontFamily: 'Poppins'),
          type: BottomNavigationBarType.fixed,
          backgroundColor: AppColors.pageBackground,
          currentIndex: navController.selectedIndex,
          onTap: (index) {
            navController.updateSelectedIndex(index);
            onItemSelected(navItems[index].menuCode);
          },
        ),
      ),

On devices like the S23, the bottom navigation bar overflows or gets partially hidden behind the system nav bar. enter image description here

3 Answers 3

5

Your scenario is unusual because you shouldn't encounter that if you construct your widget correctly, like this:

@override
Widget build(BuildContext context) {
  return Scaffold(
    body: YourWidgetBodyHere(),
    bottomNavigationBar: BottomNavigationBar(
      key: bottomNavKey,
      items: _navItemBuilder(navItems),
      elevation: 10,
      showSelectedLabels: true,
      showUnselectedLabels: true,
      selectedFontSize: 10,
      unselectedFontSize: 10,
      selectedLabelStyle: TextStyle(fontFamily: 'Poppins'),
      type: BottomNavigationBarType.fixed,
      backgroundColor: AppColors.pageBackground,
      currentIndex: navController.selectedIndex,
      onTap: (index) {
        navController.updateSelectedIndex(index);
        onItemSelected(navItems[index].menuCode);
      },
    ),
  );
}

By placing your BottomNavigationBar widget in the bottomNavigationBar property of Scaffold, the layout should treat your widget solely as the bottomNavigationBar and prevent it from overflowing.

However, if it overlaps the bottom area of the available screen height.

It's usually because the height or size of your icons and their labels are overlapping the available height of your BottomNavigationBar widget.

Sign up to request clarification or add additional context in comments.

Comments

1

When I encountered this issue, I resolved the overlapping problem globally by adding the following code:

MaterialApp(
  builder: (context, child) {
    return SafeArea(
      top: false, // Set to true if you want to avoid notch overlap too
      bottom: true, // Avoids overlap with navigation bar
      child: child!,
    );
  },
  home: YourHomePage(), // Or your main screen
);

Comments

1

For anyone else, I also encountered this in One UI 7. But I had already placed the BottomNavigationBar within the Scaffold's BottomNavigationBar, the issue was that I had defined the height. Just deleting the height solved it.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.