Home > Net >  how to place ads below or above BottomNavigationBar in Flutter
how to place ads below or above BottomNavigationBar in Flutter

Time:01-07

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 childs 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 place for google_mobile_ads just above or below the bottomnavigationbar?

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

CodePudding user response:

Wrap in a column in MaterialApp and expand Scaffold body to fill Ad to the bottom

MaterialApp:
       Column(:[
            Expanded(Scaffold),
            AdWidget,
        ])

CodePudding user response:

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()
                                    ]
                         )
                     )
  •  Tags:  
  • Related