getCustomAd static method

CustomAdModel? getCustomAd({
  1. int? index,
})

Retrieves a custom ad by index, or a random custom ad, or null if none registered.

Implementation

static CustomAdModel? getCustomAd({int? index}) {
  if (_customAds.isEmpty) return null;
  if (index != null && index >= 0 && index < _customAds.length) {
    return _customAds[index];
  }
  return _customAds[Random().nextInt(_customAds.length)];
}