MaxAdView class
Displays a native AdView for a banner or MREC ad using a platform view as its container.
This widget can be used to display:
- Banners: 320×50 on phones, 728×90 on tablets.
- MRECs: Fixed size of 300×250 on all devices.
All ad formats are rendered through a native AdView behind the scenes, ensuring consistent behavior across platforms.
For adaptive banner sizing, use AppLovinMAX.getAdaptiveHeightForWidth()
to determine the appropriate height.
Preloading: If you preload an ad using AppLovinMAX.preloadWidgetAdView(), pass the returned AdViewId to this widget to display the preloaded instance.
Example:
MaxAdView(
adUnitId: 'your_ad_unit_id',
adFormat: AdFormat.banner,
listener: AdViewAdListener(
onAdLoadedCallback: (ad) {},
onAdLoadFailedCallback: (adUnitId, error) {},
onAdClickedCallback: (ad) {},
onAdExpandedCallback: (ad) {},
onAdCollapsedCallback: (ad) {},
onAdRevenuePaidCallback: (ad) {},
),
);
For a complete implementation example, see: https://github.com/AppLovin/AppLovin-MAX-Flutter/blob/master/applovin_max/example/lib/main.dart
Note: The AppLovin SDK must be initialized before using this widget.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- MaxAdView
Constructors
-
MaxAdView.new({Key? key, required String adUnitId, required AdFormat adFormat, AdViewId? adViewId, String? placement, String? customData, Map<
String, String?> ? extraParameters, Map<String, dynamic> ? localExtraParameters, AdViewAdListener? listener, bool isAutoRefreshEnabled = true, double? width, double? height}) -
Creates an AdView ad that embeds directly into the widget tree.
const
Properties
- adFormat → AdFormat
-
The ad format to load. Must be either AdFormat.banner or AdFormat.mrec.
final
- adUnitId → String
-
The ad unit ID to load ads for.
final
- adViewId → AdViewId?
-
Unique identifier used to reference the platform AdView instance.
final
- customData → String?
-
Custom data string for granular ad reporting.
final
-
extraParameters
→ Map<
String, String?> ? -
Additional key-value parameters for ad customization, passed to the SDK.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double?
-
The ad height. If
null
, a default is computed based on adFormat and layout constraints.final - isAutoRefreshEnabled → bool
-
Whether auto-refresh is enabled. Defaults to
true
.final - key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- listener → AdViewAdListener?
-
Listener for ad event callbacks.
final
-
localExtraParameters
→ Map<
String, dynamic> ? -
Local extra parameters provided to mediation adapters for further customization.
final
- placement → String?
-
Placement name assigned for granular ad reporting.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- width → double?
-
The ad width. If
null
, a default is computed based on adFormat and layout constraints.final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited