load static method

Future<void> load({
  1. required String placementId,
  2. dynamic onComplete(
    1. String placementId
    )?,
  3. dynamic onFailed(
    1. String placementId,
    2. UnityMediationAdsLoadError error,
    3. String errorMessage
    )?,
})

Load a placement to make it available to show. Ads generally take a few seconds to finish loading before they can be shown.

  • placementId - the placement ID, as defined in Unity Ads admin tools.
  • onComplete - callback triggered when a load request has successfully filled the specified placementId with an ad that is ready to show.
  • onFailed - called when load request has failed to load an ad for a requested placement.

Implementation

static Future<void> load({
  required String placementId,
  Function(String placementId)? onComplete,
  Function(String placementId, UnityMediationAdsLoadError error, String errorMessage)?
  onFailed,
}) async {

  UnityAdsBase.channels
      .putIfAbsent(
          placementId, () => MethodChannel('${rewardedAdChannel}_$placementId'))
      .setMethodCallHandler(
          (call) => _loadMethodCall(call, onComplete, onFailed));

  final arguments = <String, dynamic>{
    placementIdParameter: placementId,
  };

  await UnityAdsBase.channel.invokeMethod(rewardedAdLoadMethod, arguments);
}