loadAdaptive method

Future<bool> loadAdaptive({
  1. required double screenWidth,
  2. bool collapsible = false,
  3. bool isLarge = false,
})

Load an adaptive banner. Must be called with screen width.

Implementation

Future<bool> loadAdaptive({
  required double screenWidth,
  bool collapsible = false,
  bool isLarge = false,
}) async {
  if (state == AdState.loading) return false;

  final width = screenWidth.truncate();
  final size = isLarge
      ? (await AdSize.getLargeAnchoredAdaptiveBannerAdSize(width) ??
            // ignore: deprecated_member_use
            await AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(
              width,
            ))
      // ignore: deprecated_member_use
      : (await AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(
              width,
            ) ??
            await AdSize.getLargeAnchoredAdaptiveBannerAdSize(width));
  if (size == null) return false;

  _adSize = size;
  return _loadWithSize(size, collapsible: collapsible);
}