how to place ads below or above BottomNavigationBar in Flutter

Viewed 575

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.

3 Answers

That's how I dealt with it

bottomNavigationBar: Column(
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.end,
        children: [
          AdvertisementWidget(),
          BottomNavigationBar(),
        ],
      )

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

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

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