Search code examples
flutterdartflutter-bottomnavigationgoogle-mobile-ads

how to place ads below or above BottomNavigationBar in Flutter


I want to place google_mobile_ads Banner Ad just above or below the BottomNavigationBar in Flutter.

I tried to place the BottomNavigationBar in Container ad add Margin, but there is no option to add 2 children inside the Container.

I tried to add a Column widget inside the BottomNavigationBar but the column goes to the up top of the page.

Any ideas on how I can make a place for google_mobile_ads just above or below the BottomNavigationBar?

I can share the code, but I need advice or guidance or pointers on how it can be achieved.


Solution

  • There are many ways to achieve this. one would be to separate your scaffold and Ad container like this:

    return Column(
        children:[
            Expanded(child: Scaffold(),
            SizedBox(height: 50, child: AdContainer())
        ]
    )
    

    another way would be to add it in the bottom nav bar:

    bottomNavigationBar: SizedBox(
                             height = 200,
                             child: Column(
                                        children: [
                                            BottomNav(),
                                            AdContainer()
                                        ]
                             )
                         )