4

I'm building a flutter app and I used the BottomNavigationBar widget everything seems to work fine but the color of the Navigation bar is not blending with the device navigation space. (The place where the home button recides).

Below is something what I'm looking for 👇 This is how my app is looking currently.

I want the colors of both 1 & 2 to be the same. Simply I want the color of 2same as the bottom navigation bar.

I also used Material 3 for this app.

This is my current implementation.

class BottomNavbar extends StatelessWidget {
  const BottomNavbar({super.key});

  void _onTap(int index, BuildContext context) {...}

  int _calculateSelectedIndex(BuildContext context) {...}

  @override
  Widget build(BuildContext context) {
    return NavigationBar(
      selectedIndex: _calculateSelectedIndex(context),
      onDestinationSelected: (int index) => _onTap(index, context),
      destinations: const [
        NavigationDestination(
          label: "Home",
          icon: Icon(
            Icons.home_filled,
          ),
          tooltip: "Home",
        ),
        NavigationDestination(
          label: "Collections",
          icon: Icon(
            Icons.bookmarks_outlined,
          ),
          tooltip: "Collections",
        ),
      ],
    );
  }
}
class MainScaffold extends StatelessWidget {
  final Widget child;
  const MainScaffold({super.key, required this.child});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      drawer: const MemitDrawer(),
      appBar: const MemitAppBar(),
      body: child,
      floatingActionButton: FloatingActionButton(...),
      bottomNavigationBar: const BottomNavbar(),
    );
  }
}
5
  • 1
    please provide the code you have tried. Commented Jan 31, 2023 at 4:46
  • @baek I updated the question with my current implementation. Commented Jan 31, 2023 at 14:41
  • This code is working fine for me on both ios and android without the bottom, are you using SafeArea anywhere in your code, perhaps your main file? Commented Feb 1, 2023 at 5:49
  • I'm using the go_router package for routing and the MainScaffold widget in my implementation is a shell route. Will that contribute to the problem ? Commented Feb 1, 2023 at 7:24
  • Is it because I'm using a custom theme data to change the in app theme (light) and the system theme (my device's) is dark. @baek Commented Feb 1, 2023 at 16:09

0

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.