我在项目中使用rxDart包,并以流的形式从服务器获取数据,添加了firebase_admob并在应用程序中显示广告,但是当横幅广告改变时,我的流将自动启动。 为什么这样?
我尝试了从其他地方调用FirebaseAdMob
@override
initState() {
super.initState();
bloc.loginUser();
bloc.onPositionChanged();
bloc.inAnimate.add(false);
bloc.inMapZoom.add(18.0);
bloc.inScreenVisible.add(Screen.main);
bloc.pushNotification();
FirebaseAdMob.instance.initialize(appId: appId);
bloc.adsBanner();
}
StreamBuilder<ReportData>(
stream: bloc.outAllVicinity,
builder: (context, vicinitySnapshot) {
if (vicinitySnapshot.hasData) {
if (vicinitySnapshot.data != null) {
_setReportsList(vicinitySnapshot.data);
return Positioned(
top: 8.0,
child: Text(("all reports
${vicinitySnapshot.data.data.length}")));
} else {
return Positioned(
top: 8.0,
child: Text(("${vicinitySnapshot.data.error} "
)));
}
}
if (vicinitySnapshot.error != null) {
return Positioned(
top: 8.0, child: Text("Some trouble in
outAllVicinity"));
}
return Container();
},
),
StreamBuilder<ReportData>(
stream: bloc.outInVicinity,
builder: (context, inVicinitySnapshot) {
if (inVicinitySnapshot.hasData) {
_setReportsListFindQuest(inVicinitySnapshot.data);
return Positioned(
top: 20.0,
child: Text((" invicinity reports
${inVicinitySnapshot.data.data.length} "
"\n markers count ${markers.length}")));
}
return Container();
},
),
每次广告更改时,数据都会自动从流中传给我。