Created
July 11, 2020 06:47
-
-
Save Anirudhk07/87c1484ae0d1f08b206b3848d6d55798 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _GameRouteState extends State<GameRoute> implements QuizEventListener { | |
... | |
// TODO: Add _isRewardedAdReady | |
bool _isRewardedAdReady; | |
... | |
// TODO: Implement _loadRewardedAd() | |
void _loadRewardedAd() { | |
RewardedVideoAd.instance.load( | |
targetingInfo: MobileAdTargetingInfo(), | |
adUnitId: AdManager.rewardedAdUnitId, | |
); | |
} | |
// TODO: Implement _onRewardedAdEvent() | |
void _onRewardedAdEvent(RewardedVideoAdEvent event, | |
{String rewardType, int rewardAmount}) { | |
switch (event) { | |
case RewardedVideoAdEvent.loaded: | |
setState(() { | |
_isRewardedAdReady = true; | |
}); | |
break; | |
case RewardedVideoAdEvent.closed: | |
setState(() { | |
_isRewardedAdReady = false; | |
}); | |
_loadRewardedAd(); | |
break; | |
case RewardedVideoAdEvent.failedToLoad: | |
setState(() { | |
_isRewardedAdReady = false; | |
}); | |
print('Failed to load a rewarded ad'); | |
break; | |
case RewardedVideoAdEvent.rewarded: | |
QuizManager.instance.useHint(); | |
break; | |
default: | |
// do nothing | |
} | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment