问题
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