show method
Shows a previously loaded ad. Completes when the ad is presented (or failed to present), not when it is closed.
Implementation
@override
Future<AdResult<void>> show(AdHandle handle) async {
if (!isReady(handle)) {
return AdFailure(
AdError(
code: AdErrorCode.notReady,
message: 'fake ad not loaded',
network: network,
),
);
}
final error = showError;
if (error != null) return AdFailure(error.copyWith(network: network));
_loaded.remove(handle.id);
shown.add(handle);
emit(AdShown(network: network, adId: handle.id, format: handle.format));
emit(
AdImpression(network: network, adId: handle.id, format: handle.format),
);
if (handle.format.isRewarded) {
emit(
AdEarnedReward(
network: network,
adId: handle.id,
format: handle.format,
reward: reward,
),
);
}
if (autoCloseOnShow) simulateClose(handle);
return const AdSuccess(null);
}