当我拿起http请求列表时遇到了一个问题,当我转到选项卡页面并返回其原始页面时,该请求继续增加(请参见图片以了解结果)。
然后,在离开另一页并返回原始页面之后
如何优化呢?
请参阅下面的代码:
import numpy as np
drand = data.iloc[np.random.choice(np.arange(data.size), n, replace=False)]
此处为fetchStandingTeams()方法
class HomeTabDetail extends StatefulWidget {
final Fixture fixture;
final FixtureModel model;
HomeTabDetail({this.fixture, this.model});
@override
_HomeTabDetailState createState() => _HomeTabDetailState();
}
class _HomeTabDetailState extends State<HomeTabDetail>
with SingleTickerProviderStateMixin {
TabController controller;
// BannerAd bannerAd;
@override
void initState() {
super.initState();
loadData();
print('initstate called');
controller = TabController(vsync: this, length: 4);
// FirebaseAdMob.instance.initialize(appId: FirebaseAdMob.testAppId);
// bannerAd = buildBanner()..load();
}
@override
void dispose() {
// bannerAd?.dispose();
controller.dispose();
print('dispose called');
super.dispose();
}
static final targetingInfo = MobileAdTargetingInfo(
keywords: <String>['flutterio', 'beautiful apps'],
contentUrl: 'https://flutter.io',
childDirected: false,
testDevices: <String>[], // Android emulators are considered test devices
);
BannerAd buildBanner() {
return BannerAd(
adUnitId: BannerAd.testAdUnitId,
size: AdSize.smartBanner,
targetingInfo: targetingInfo,
listener: (MobileAdEvent event) {
print("bannerAd event is $event");
});
}
Future loadData() async {
await Future.wait([
widget.model.fetchVenue(widget.fixture.venueId.toString()),
widget.model.fetchCountry(widget.fixture.league.countryId.toString()),
widget.model.fetchStandingTeams(widget.fixture.season.id.toString())
]);
}
@override
Widget build(BuildContext context) {
// bannerAd.show();
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: Text('Info Pertandingan'),
bottom: TabBar(
controller: controller,
tabs: <Widget>[
Tab(text: 'RINCIAN'),
Tab(text: 'MEDIA'),
Tab(text: 'LINEUP'),
Tab(text: 'KLASEMEN'),
],
),
),
body: ScopedModelDescendant<FixtureModel>(
builder: (context, child, model) {
return TabBarView(
controller: controller,
children: <Widget>[
DetailMatchTab(widget.fixture),
MediaMatchTab(),
LineupMatchTab(),
KlasemenMatchTab()
],
);
}));
}
}