Skip to content

Commit d24848f

Browse files
committed
refactor(admob): add timeout constant for native ads
- Introduce a static constant `_nativeAdLoadTimeout` with a value of 15 seconds - Replace the hardcoded timeout value with the new constant
1 parent faead38 commit d24848f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/ads/admob_ad_provider.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class AdMobAdProvider implements AdProvider {
2424
final Logger _logger;
2525
final Uuid _uuid = const Uuid();
2626

27+
static const _nativeAdLoadTimeout = 15;
28+
2729
/// The AdMob Native Ad Unit ID for Android.
2830
///
2931
/// This should be replaced with your production Ad Unit ID.
@@ -123,7 +125,7 @@ class AdMobAdProvider implements AdProvider {
123125

124126
// Add a timeout to the future to prevent hanging if callbacks are not called.
125127
final googleNativeAd = await completer.future.timeout(
126-
const Duration(seconds: 15),
128+
const Duration(seconds: _nativeAdLoadTimeout),
127129
onTimeout: () {
128130
_logger.warning('Native ad loading timed out.');
129131
ad.dispose(); // Dispose the ad if it timed out

0 commit comments

Comments
 (0)