openRewards method
void
openRewards()
Opens the rewards page: waiting chances and won rewards, shown full
screen over the app. The page URL resolves from getRewards (at most
4 s), else the environment default. A game still loading (or on screen)
would otherwise end up behind the page and block the games opened from
it, so it closes first as superseded. The page refreshes on appear and
after every game close. Below the OS floor it is a no-op. Never throws.
Implementation
void openRewards() {
try {
if (!_gamificationSurface.isOsSupported()) {
_log.d('openRewards ignored — OS below the game floor');
return;
}
final navigator = _navigator;
if (navigator == null) {
_log.d('openRewards ignored — no navigator attached');
return;
}
unawaited(() async {
try {
await GameSurface.dismissSuperseded(navigator);
await navigator.push(
MaterialPageRoute<void>(
fullscreenDialog: true,
builder: (context) => RewardsScreen(
resolvePageUrl: _resolveRewardsPageUrl,
initOf: () => _rewardsInit(context),
openGame: (chanceId, campaignId) => openGameForChance(
chanceId,
campaignId: campaignId,
),
openLink: _openRewardsLink,
copyText: copyRewardsText,
),
),
);
} catch (e) {
_log.w('openRewards failed ($e)');
}
}());
} catch (_) {}
}