Closed aleksandar-radivojevic closed 4 years ago
So I use init() in main() function of the app, and showBanner() in initState of single news page.
@override
void initState() {
AppAds.showBanner();
super.initState();
}
@override
void dispose() {
AppAds.dispose();
imageCache.clear();
super.dispose();
}
Flutter doctor:
[✓] Flutter (Channel stable, v1.9.1+hotfix.6, on Mac OS X 10.15.1 19B88, locale en-RS) • Flutter version 1.9.1+hotfix.6 at /Users/luja/Desktop/code/flutter • Framework revision 68587a0916 (8 weeks ago), 2019-09-13 19:46:58 -0700 • Engine revision b863200c37 • Dart version 2.5.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0) • Android SDK at /Users/luja/Library/Android/sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405) • All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 11.1, Build version 11A1027 • CocoaPods version 1.8.3
[✓] Android Studio (version 3.5) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 40.2.2 • Dart plugin version 191.8593 • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] Connected device (1 available) • iPhone 8 • D78B9FDA-C30B-4215-8301-A731D4C3C27E • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-1 (simulator)
@aleksandar-radivojevic
Excellent, Aleksandar! You're code looks good.
Let's try a few things and see what happens. First, let's not even call dispose() and let the phone 'dispose' of resources itself. It sounds counter-intuitive, I know, but let's see what happens.
Secondly, instead of AdSize.fullBanner, please try the default size, AdSize.banner. With that, I wonder if you'll experience the same laggy performance. It may turn out it's the plugin, firebase_admob, used by this package that may be the culprit, but we'll do some testing here first and see what happens.
Thanks.
Greg
@Andrious Well when I dont call dispose() method banner ad stays when navigating back to main screen. I have just changed dispose method to a different function and it's seems like its working better now. Just need a couple of more test to be sure.
static void hideBanner() => ads.removeBannerAd();
This is what I use in dispose() method of single news page
I can confirm that app is great again, it's working much better. So I just used ads.removeBannerAd() instead of ads.dispose() and thats all.
But I have one more issue which is that ads sometimes not covering ad area. Please look at screenshots for details, sometimes its covering all available space sometimes not.
In screenshots I user AdSize.smartBanner but issue is exactly the same with banner, fullBanner and all other options. What can be the cause of this?
Excellent! Yes, the dispose() is currently using ads.closeBannerAd(); and not ads.removeBannerAd(); However, dispose() will use ads.removeBannerAd(); in the next release coming out this week. Unlike ads.closeBannerAd(), ads.removeBannerAd() removes the Ad from memory and doesn't reload it back up again.
"...ads sometimes not covering ad area."
Well, that is interesting. Sometime it covers the area and sometimes it doesn't???
Strange.
Off the top of my head I can only suspect the plugin itself is being a problem.
I wonder if the three 'placement options' would allow you to instruct the exact size of the Ad?:
anchorOffset
horizontalCenterOffset
anchorType
Placement options not working for me. It would be nice to have sth like BoxFit.cover :D :D
:) Yes, yes it would.
I'm also getting this warning on IOS simulator:
FirebaseAdMobPlugin
As with the placement problem, I feel you'll find a possible solution with the authors of the plugin, firebase_admob.
Asking the same questions with them may get you immediate answer: New Issue
Possibly you're not the only one with such issues, and has already been asked under issues.
Hey guys, I'm having problems with your plugin, when I add ads performance of my app drops.
First thing that I've noticed is that dispose() method needs around 3 seconds to dispose ads and while is doing that its using a lot of resources and apps gets laggy.
Second thing.. My main screen is a list of news, and when user tap on news he gets navigated to single news page where I want to show banner ad. If I put init() function in initState() of single news page, sometimes it needs a lot of time in order to load banner and if in meantime I navigate back(Navigator.pop) than banner gets stucked in my main page (when it loads), where I dont want it to be, so I put in in main() function of the app, but now scrolling through main screen(list of news) is kinda choppy..
Please take a look at my code and tell me if I implemented sth wrong or give me some idea how can I optimize code..