CompanionAdSlot class
Ad slot for companion ads.
Platform-Specific Features
This class contains an underlying implementation provided by the current platform. Once a platform implementation is imported, the examples below can be followed to use features provided by a platform's implementation.
Below is an example of setting platform-specific creation parameters for iOS and Android:
PlatformCompanionAdSlotCreationParams params =
const PlatformCompanionAdSlotCreationParams();
if (InteractiveMediaAdsPlatform.instance is IOSInteractiveMediaAdsPlatform) {
params = IOSCompanionAdSlotCreationParams
.fromPlatformCompanionAdSlotCreationParams(
params,
);
} else if (InteractiveMediaAdsPlatform.instance is AndroidInteractiveMediaAdsPlatform) {
params = AndroidCompanionAdSlotCreationParams
.fromPlatformCompanionAdSlotCreationParams(
params,
);
}
final CompanionAdSlot slot = CompanionAdSlot.fromPlatformCreationParams(
params,
);
Below is an example of accessing the platform-specific implementation for iOS and Android:
final CompanionAdSlot slot = CompanionAdSlot.size(width: 100, height: 100);
if (InteractiveMediaAdsPlatform.instance is IOSInteractiveMediaAdsPlatform) {
final IOSCompanionAdSlot iosSlot = slot.platform as IOSCompanionAdSlot;
} else if (InteractiveMediaAdsPlatform.instance is AndroidInteractiveMediaAdsPlatform) {
final AndroidCompanionAdSlot androidSlot =
slot.platform as AndroidCompanionAdSlot;
}
Constructors
- CompanionAdSlot({required CompanionAdSlotSize size, void onClicked()?})
- Constructs an instance of a CompanionAdSlot.
- CompanionAdSlot.fromPlatform(PlatformCompanionAdSlot platform)
-
Constructs a CompanionAdSlot from a specific platform implementation.
const
- CompanionAdSlot.fromPlatformCreationParams({required PlatformCompanionAdSlotCreationParams params})
- Constructs a CompanionAdSlot from creation params for a specific platform.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- onClicked → void Function()?
-
Called when the slot is clicked on by the user and will successfully
navigate away.
no setter
- platform → PlatformCompanionAdSlot
-
Implementation of
PlatformCompanionAdSlotfor the current platform.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
buildWidget(
BuildContext context) → Widget - Builds the Widget that contains the native View.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited