How to position Firebase Admob on the bottom after keyboard is closed in Flutter?

孤街醉人 提交于 2020-12-13 05:57:10

问题


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?


回答1:


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,
)



回答2:


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
    },
  );


来源:https://stackoverflow.com/questions/60348563/how-to-position-firebase-admob-on-the-bottom-after-keyboard-is-closed-in-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!