loadBanner method

  1. @override
Future<Widget> loadBanner(
  1. int zoneId, {
  2. BannerAdSize adSize = BannerAdSize.standard,
})
override

Implementation

@override
Future<Widget> loadBanner(int zoneId,
    {BannerAdSize adSize = BannerAdSize.standard}) async {
  double width = 320, height;
  switch (adSize) {
    case BannerAdSize.standard:
      height = 50;
      break;
    case BannerAdSize.landscape:
      height = 90;
      break;
    case BannerAdSize.rectangle:
      height = 250;
      break;
  }
  try {
    return Center(
      child: SizedBox(
        width: width,
        height: height,
        child: AndroidView(
          viewType: "Notix_banner",
          // Pass parameters to the native view
          creationParams: {
            'zoneId': zoneId,
            'adSize': adSize.toString().split('.').last
          },
          creationParamsCodec: const StandardMessageCodec(),
        ),
      ),
    );
  } catch (e) {
    log("Notix Channel Method error = $e");
  }
  return const Center(
    child: Text("Fail to load Ad"),
  );
}