0
Good evening, I’m having a little trouble adding an ad to every x item on my list.
Searching I found this piece of code
void _getData() {
for (int i = 0; i < imageList.length; i++) {
var image = ImageClass();
if (i != 0) {
if (i % 5 == 0) {
//Below image.type = "GoogleAds" is Going to the show Ads
image.type = "GoogleAd";
} else {
//Below image.type is Goign to SHow Images
image.type = "";
image.images = imageList[i];
}
_list.add(image);
} else {
image.type = "";
image.images = imageList[i];
_list.add(image);
}
}
}
But how do I implement this in my code? I’ve tried several solutions and it never works by Random. Either stay in one location, or keep repeating every item in the list.
This is my code that plays and adds the ad container.
Widget adsContainer() {
return Container(
height: 250,
child: NativeAdmob(
adUnitID: _adUnitID,
controller: _nativeAdController,
type: NativeAdmobType.full,
),
);
}
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Container(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ListView.builder(
itemCount: list == null ? 0 : list .length,
itemBuilder: (context, index) {
return InkWell(
onTap: () {
print(list[index].id);
Navigator.of(context).push(MaterialPageRoute(builder: (context) => DetailPage(text: list[index].id)));
}, child: Stack(children: [
_imageSpace(list[index].image),
_colorsSpace(list[index].colors),
_nameSpace(list[index].name),
_infoSpace(list[index].info),
]));
},
),
adsContainer(), //displaying ad on bottom of everything
],
),
),
);
}
}
Important you [Dit] your question and explain objectively and punctually the difficulty found, accompanied by a [mcve] of the problem and attempt to solve. To better enjoy the site, understand and avoid closures and negativations worth reading What is the Stack Overflow and then the Stack Overflow Survival Guide (summarized) in Portuguese.
– Bacco