fix(home): 修复 feed 更新触发的 build 期 setState

This commit is contained in:
Zhou Weidong committed 2026-10-21 19:45:38 +08:00
1 parent 862b7e92dd
commit d227ac69fb
6 files changed
+174 -10

No files matched your search

+13 -1
View File
@@ -1,6 +1,7 @@
// Author: fruit.com.cn
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import '../../core/data/models/drama.dart';
import '../discover/discover_types.dart';
@@ -22,6 +23,7 @@ class HomeLogic extends ChangeNotifier {
bool drawerOpen = false;
bool detailOpen = false;
bool videoImmersive = false;
bool _dramaNotifyScheduled = false;
bool _disposed = false;
void notify() {
@@ -120,7 +122,17 @@ class HomeLogic extends ChangeNotifier {
void onDramaChanged(Drama drama) {
currentDrama = drama;
notify();
if (SchedulerBinding.instance.schedulerPhase == SchedulerPhase.idle) {
notify();
return;
}
if (_dramaNotifyScheduled || _disposed) return;
_dramaNotifyScheduled = true;
WidgetsBinding.instance.addPostFrameCallback((_) {
_dramaNotifyScheduled = false;
if (!_disposed) notify();
});
SchedulerBinding.instance.scheduleFrame();
}
void onImmersiveChanged(bool value) {