flutter_native_admob
flutter_native_admob copied to clipboard
[Question] about numberAds param
Hi,
I'd like to ask about the numberAds param. It's hard for me to figure out how to use it and what it does. I am very new to flutter.
I thought it would cache 4 ads and show the cache with the index. Isn't this how it's supposed to work? I put up my code below. It just shows the same ad everywhere.
There are not much of docs or example around it.
reloadAddoes not seem to do the job either. ( does not render another ad )
Ultimately, what I am trying to do is preloading ads before the render.
Thanks for the awesome project.
import 'package:flutter/material.dart';
import 'package:flutter_native_admob/flutter_native_admob.dart';
import 'package:flutter_native_admob/native_admob_controller.dart';
class AdmobPage4 extends StatefulWidget {
@override
_AdmobPage4State createState() => _AdmobPage4State();
}
class _AdmobPage4State extends State<AdmobPage4> {
static const _adUnitID = "ca-app-pub-5046562646162404/5259802678";
NativeAdmobController _nativeAdController;
@override
void initState() {
_nativeAdController = NativeAdmobController();
_nativeAdController.setTestDeviceIds(["C3F8FA9E55B3AE3C8D581B59F724E8B0"]);
super.initState();
}
@override
void dispose() {
_nativeAdController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: ListView.builder(
itemCount: 200,
itemBuilder: (context, index) {
if (index % 4 == 0) {
int idx = (index / 4).floor();
return Container(
height: 330,
padding: EdgeInsets.all(10),
margin: EdgeInsets.only(bottom: 20.0),
child: NativeAdmob(
numberAds: idx,
loading: Container(color: Colors.red),
adUnitID: _adUnitID,
controller: _nativeAdController,
),
);
}
return Container(
margin: EdgeInsets.only(bottom: 20.0),
height: 200.0,
color: Colors.green,
);
},
),
),
);
}
}
I can't figure out how it works, I tried use this param to get different ads in a ListView but it doesn't work. Does someone know?
any update on this?
Any update on this question, it has been more than 1 year?