NativeAdCarousel class

A Flutter widget that displays a carousel of native advertisements.

This widget creates a scrollable carousel (horizontal or vertical) of native ads, each displaying product information like name, price, image, and other details. It's equivalent to the Android NativeAdCarouselView.

Example usage:

NativeAdCarousel(
  adData: {
    "ad": listOfNativeAds,
  },
  adType: NativeAdType.verticalLarge,
  width: 300,
  height: 400,
  elementWidth: 200,
  config: osmosConfig,
  onAdClicked: (ad) {
    print('Native Ad clicked: $ad');
  },
  onViewLoad: (ad) {
    print('Native Ad loaded: $ad');
  },
)
Inheritance

Constructors

NativeAdCarousel({Key? key, required Map<String, dynamic> adData, required NativeAdType? adType, required double width, required OsmosConfig config, double? height, double? elementWidth, double? elementHeight, String? adLabelText, Alignment? adLabelAlignment, NativeAdStyle? customStyle, Widget? customCtaView, Widget? customBadgeView, void onAdClicked(Map<String, dynamic>)?, void onViewLoad(Map<String, dynamic>)?, void errorCallback(String error)?})
const

Properties

adData Map<String, dynamic>
Map containing native ad data structure Expected to include a key "ad" with value of type List
final
adLabelAlignment Alignment?
Alignment for ad label
final
adLabelText String?
Text for ad label (e.g., "Sponsored")
final
adType NativeAdType?
Type of native ad (verticalSmall, verticalMedium, verticalLarge, horizontalSmall, horizontalLarge)
final
config OsmosConfig
SDK configuration object
final
customBadgeView Widget?
Custom badge view widget
final
customCtaView Widget?
Custom CTA view widget
final
customStyle NativeAdStyle?
Custom styling for the native ads
final
elementHeight double?
Height of individual native ad elements (optional)
final
elementWidth double?
Width of individual native ad elements (optional)
final
errorCallback → void Function(String error)?
Optional error callback
final
hashCode int
The hash code for this object.
no setterinherited
height double?
Height of native ad carousel in pixels (optional)
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onAdClicked → void Function(Map<String, dynamic>)?
Callback when an ad is clicked
final
onViewLoad → void Function(Map<String, dynamic>)?
Callback when an ad view is loaded/visible
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
width double
Width of native ad carousel in pixels
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<NativeAdCarousel>
Creates the mutable state for this widget at a given location in the tree.
override
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