Widget nativeAdView(BuildContext context) {
if (!isLoaded) return Container();
return Container(
margin: const EdgeInsets.symmetric(vertical: 16),
decoration: BoxDecoration(
border: Border.all(color: Colors.black),
),
width: MediaQuery.of(context).size.width,
child: AdropNativeAdView(
ad: nativeAd,
child: Container(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.network(
nativeAd?.properties.profile?.displayLogo ?? '',
width: 24,
height: 24,
),
const SizedBox(
width: 4,
),
Text(
nativeAd?.properties.profile?.displayName ?? '',
)
],
),
const SizedBox(
height: 8,
),
if (nativeAd?.properties.headline != null)
Text(
nativeAd?.properties.headline ?? '',
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
if (nativeAd?.properties.body != null)
Text(
nativeAd?.properties.body ?? '',
style: const TextStyle(
fontSize: 14,
),
),
if (nativeAd?.properties.asset != null)
Column(children: [
const SizedBox(
height: 4,
),
Image.network(
nativeAd?.properties.asset ?? '',
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress == null) return child;
return const CupertinoActivityIndicator();
},
errorBuilder: (context, error, stackTrace) {
return const Icon(Icons.error);
},
width: MediaQuery.of(context).size.width,
height: 300,
)
]),
if (nativeAd?.properties.extra['t1'] != null)
Column(
children: [
const SizedBox(
height: 8,
),
Text(
nativeAd?.properties.extra['t2'] ?? '',
style: const TextStyle(
fontSize: 14,
),
),
Text(
nativeAd?.properties.extra['t3'] ?? '',
style: const TextStyle(
fontSize: 14,
),
),
],
)
],
),
),
),
);
}