Firebase 如何在带分页的Flatter中显示listview.builder中的本机广告?
我正在使用下面的代码在Flatter应用程序中检索列表,使用firestore作为数据库进行分页,工作正常。我指的是本地广告的Firebase 如何在带分页的Flatter中显示listview.builder中的本机广告?,firebase,flutter,google-cloud-firestore,pagination,native-ads,Firebase,Flutter,Google Cloud Firestore,Pagination,Native Ads,我正在使用下面的代码在Flatter应用程序中检索列表,使用firestore作为数据库进行分页,工作正常。我指的是本地广告的flatter\u native\u admob依赖关系。但我不知道如何在listview.builder中实现它,同时我需要实现分页。 就像在instagram中一样,在发布一定数量的帖子后,本地广告就会出现,我需要以类似的方式显示附加内容。这怎么可能 _getProducts() async { query = Firestore.instance.col
flatter\u native\u admob
依赖关系。但我不知道如何在listview.builder
中实现它,同时我需要实现分页。
就像在instagram中一样,在发布一定数量的帖子后,本地广告就会出现,我需要以类似的方式显示附加内容。这怎么可能
_getProducts() async {
query = Firestore.instance.collection("users").document(uid).collection('my_favorites').orderBy("timestamp", descending: true).limit(5);
setState(() {
_loadingnotifications = true ;
});
QuerySnapshot _querySnapshot = await query.getDocuments();
_lastDocument = _querySnapshot.documents[_querySnapshot.documents.length - 1];
_notifications = _querySnapshot.documents;
setState(() {
_loadingnotifications = false;
});
}
_getMoreNotifications() async {
print("new docs loaded");
if(_moreProductsAvailable == false ){
return;
}
if(_loadingMore == true ){
return;
}
_loadingMore = true;
query = Firestore.instance.collection("users").document(uid).collection('my_favorites').orderBy("timestamp", descending: true).startAfter([_lastDocument.data['timestamp']]).limit(5);
QuerySnapshot _querySnapshot = await query.getDocuments();
if (_querySnapshot.documents.length <5){
_moreProductsAvailable = false;
}
_lastDocument = _querySnapshot.documents[_querySnapshot.documents.length - 1];
_notifications.addAll(_querySnapshot.documents);
setState(() {
_loadingnotifications = false;
});
_loadingMore = false;
}
我知道如何创建admob帐户并在应用程序中初始化
flatter\u native\u admob
,但不知道如何将其放入列表,就像instagram和分页一样。您可以在循环中添加一个计数器变量,在将小部件添加到最终列表中之前,您可以检查每当计数器变量是5的倍数时,是否添加一个广告小部件,或者添加一个普通小部件,这将在你的列表中添加广告后,每5个正常的小部件
您可以检查此项以供参考:
有什么解决方案吗?我也在找同样的东西。
Flexible(
child:_loadingnotifications == true ? Container(child: Center(child: Text("Loading..."),),) :Container(child: _notifications.length == 0? Center(
child: Text("No Marked Posts Yet!"),) :
new ListView.builder(
controller: _scrollController,
itemCount: _notifications.length,
itemBuilder: (BuildContext ctx, int index){
String itemTitle = _notifications[index].data['itemTitle'];
return ItemCard(itemTitle: itemTitle, );
}),)
),