mod: 优化前/后台切换网络请求

This commit is contained in:
guozhigq
2023-08-07 23:05:57 +08:00
parent 1c08edb113
commit f9f995b4fb
5 changed files with 30 additions and 8 deletions

View File

@ -22,10 +22,12 @@ class LivePage extends StatefulWidget {
class _LivePageState extends State<LivePage> {
final LiveController _liveController = Get.put(LiveController());
late Future _futureBuilderFuture;
@override
void initState() {
super.initState();
_futureBuilderFuture = _liveController.queryLiveList('init');
ScrollController scrollController = _liveController.scrollController;
StreamController<bool> mainStream =
Get.find<MainController>().bottomBarStream;
@ -64,7 +66,7 @@ class _LivePageState extends State<LivePage> {
padding: const EdgeInsets.fromLTRB(
StyleString.safeSpace, 0, StyleString.safeSpace, 0),
sliver: FutureBuilder(
future: _liveController.queryLiveList('init'),
future: _futureBuilderFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
Map data = snapshot.data as Map;