Mobile Programming (MP)
Native Ads in Flutter
Native ads match your app's visual design — you control the layout.
final NativeAd _nativeAd = NativeAd(
adUnitId: 'ca-app-pub-3940256099942544/2247696110',
request: const AdRequest(),
factoryId: 'my_native_ad',
listener: NativeAdListener(
onAdLoaded: (_) => setState(() => _isLoaded = true),
onAdFailedToLoad: (ad, error) => ad.dispose(),
),
).load();
if (_isLoaded)
SizedBox(
height: 300,
width: 300,
child: AdWidget(ad: _nativeAd),
)
Note: Native ads require platform-specific code to define the ad layout.