1

I am using firebase_admob package. I use the following code and manage to make the Admob banner show on top of keyboard.

    @override
      Widget build(BuildContext context) {
        myBanner.show(
          anchorOffset: MediaQuery.of(context).viewInsets.bottom, anchorType: AnchorType.bottom)
        );

    return Scaffold(
      //Other codes
        );
    }

However, when the keyboard is closed, the banner won't move to bottom. How to solve this?

user2872856
  • 2,003
  • 2
  • 21
  • 54

2 Answers2

4

Problem solved by using [admob_flutter] package which can simply add the banner as a widget and we can position it anywhere we want.

AdmobBanner(
  adUnitId: getBannerAdUnitId(),
  adSize: AdmobBannerSize.BANNER,
)
user2872856
  • 2,003
  • 2
  • 21
  • 54
  • Anyone tried [admob_flutter] is it safe since it is not official? I haven't inspect the code so I don't know what is happening under the hood. – sultanmyrza Jul 22 '20 at 04:50
  • This plugin is good but at same time it also has some major bugs. It just crashes the app in a lot of scenarios. PLEASE TELL ANY ALTERNATIVE.... – Chirag Chopra Aug 10 '20 at 09:15
  • Should we use firebase_admob and admob_flutter? Or can we just use admob_flutter? and why we should use firebase_admob? I mean in what case? – Ray Coder Sep 26 '20 at 06:57
  • 1
    firebase_admob is the so called official package. Although admob_flutter is not officially maintained by Google team, we can see from the source code, it is using the official Admob SDK. – user2872856 Sep 27 '20 at 03:04
1

you can use keyobar_visibility plugin to change the banner place

  KeyboardVisibilityNotification().addNewListener(
    onChange: (bool visible) {
      print(visible);
      // Change the your myBanner.show parameters here with setState
      // anchorOffset and anchorType
    },
  );
cipli onat
  • 1,943
  • 1
  • 11
  • 26
  • Thanks but why with MediaQuery, I successfully made the banner move up when keyboard open, but why the banner won't move down when keyboard is closed? – user2872856 Feb 23 '20 at 00:26