How to use the rewarded video listener in flutter?
1,634
First, you are using the outdated code. This one is the latest one. Notice that it has optional named parameters {}
instead of optional positional parameters []
.
RewardedVideoAd.instance.listener =
(RewardedVideoAdEvent event, {String rewardType, int rewardAmount}) {
if (event == RewardedVideoAdEvent.rewarded) {
setState(() {
rewarded = true;
});
}
};
This is how listener works. You don't have to assign this listener to anywhere. All you need to do is call
RewardedVideoAd.instance.load(...)
Author by
ViralCode
Updated on December 08, 2022Comments
-
ViralCode over 1 year
I can't figure out how to use the listener to reward the user for watching the video.
package page : https://pub.dartlang.org/packages/firebase_admob
RewardedVideoAd.instance.listener = (RewardedVideoAdEvent event, [String rewardType, int rewardAmount]) { if (event == RewardedVideoAdEvent.rewarded) { setState(() { // Here, apps should update state to reflect the reward. _goldCoins += rewardAmount; }); } };
All I managed to do is display the ad, I have no clue how to use the listener.
This is an example: https://github.com/Maherr/listener/blob/master/lib/main.dart
How to change
rewarded
totrue
? -
questionasker almost 5 yearsHi @CopsOnRoad, where i can place
RewardedVideoAd.instance.listner
? can it place at init() ? -
CopsOnRoad almost 5 years@anunixercoder Yes, you can put it in
initState()
. -
questionasker almost 5 yearsHi @CopsOnRoad, i have put it at
initState()
but cant get ads reloaded. i have ask a question here stackoverflow.com/questions/57212679/… thank you