showNativeAd method

Widget showNativeAd({
  1. required double minWidth,
  2. required double minHeight,
  3. required double maxWidth,
  4. required double maxHeight,
})

Show the preloaded ad

Implementation

Widget showNativeAd({
  required double minWidth,
  required double minHeight,
  required double maxWidth,
  required double maxHeight,
}) {
  if (_preloadedAd == null) {
    return Container(
      width: minWidth,
      height: minHeight,
      color: Colors.white,
      alignment: Alignment.topLeft,
      child: DecoratedBox(
        decoration: BoxDecoration(
          color: Color(0xFFE88F1A),
          borderRadius: BorderRadius.only(
            bottomRight: Radius.circular(12),
          ),
        ),
        child: Padding(
          padding: const EdgeInsets.symmetric(
            horizontal: 12,
            vertical: 4,
          ),
          child: Text(
            'Ad',
            style: TextStyle(
              fontSize: 12,
              fontWeight: FontWeight.w500,
              color: Colors.white,
            ),
          ),
        ),
      ),
    );
  }

  return ConstrainedBox(
    constraints: BoxConstraints(
      minWidth: minWidth,
      minHeight: minHeight,
      maxWidth: maxWidth,
      maxHeight: maxHeight,
    ),
    child: AdWidget(ad: _preloadedAd!),
  );
}