Fix Tab destroy error
This commit is contained in:
@@ -236,6 +236,7 @@ class AppController {
|
||||
}
|
||||
|
||||
healthcheck() {
|
||||
if (globalState.healthcheckLock) return;
|
||||
for (final delay in appState.delayMap.entries) {
|
||||
setDelay(
|
||||
Delay(
|
||||
|
||||
@@ -83,12 +83,15 @@ class _ProxiesFragmentState extends State<ProxiesFragment>
|
||||
groupNames: groupNames,
|
||||
);
|
||||
},
|
||||
builder: (_, state, __) {
|
||||
if (_tabController != null) {
|
||||
_tabController!.dispose();
|
||||
_tabController = null;
|
||||
shouldRebuild: (prev,next){
|
||||
if(prev.groupNames.length != next.groupNames.length){
|
||||
_tabController?.dispose();
|
||||
_tabController =null;
|
||||
}
|
||||
_tabController = TabController(
|
||||
return prev != next;
|
||||
},
|
||||
builder: (_, state, __) {
|
||||
_tabController ??= TabController(
|
||||
length: state.groupNames.length,
|
||||
vsync: this,
|
||||
initialIndex: state.currentIndex,
|
||||
@@ -118,7 +121,6 @@ class _ProxiesFragmentState extends State<ProxiesFragment>
|
||||
children: [
|
||||
for (final groupName in state.groupNames)
|
||||
KeepContainer(
|
||||
key: ObjectKey(groupName),
|
||||
child: ProxiesTabView(
|
||||
groupName: groupName,
|
||||
),
|
||||
|
||||
@@ -23,6 +23,7 @@ class GlobalState {
|
||||
List<Function> updateFunctionLists = [];
|
||||
List<NavigationItem> currentNavigationItems = [];
|
||||
bool updatePackagesLock = false;
|
||||
bool healthcheckLock = false;
|
||||
|
||||
startListenUpdate() {
|
||||
if (timer != null && timer!.isActive == true) return;
|
||||
|
||||
@@ -38,12 +38,15 @@ class _ClashMessageContainerState extends State<ClashMessageContainer>
|
||||
|
||||
@override
|
||||
void onDelay(Delay delay) {
|
||||
context.appController.setDelay(delay);
|
||||
final appController = context.appController;
|
||||
appController.setDelay(delay);
|
||||
globalState.healthcheckLock = true;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
globalState.updateSortNumDebounce ??= debounce<Function()>(
|
||||
() {
|
||||
context.appController.updateGroups();
|
||||
context.appController.appState.sortNum++;
|
||||
() async {
|
||||
await appController.updateGroups();
|
||||
appController.appState.sortNum++;
|
||||
globalState.healthcheckLock = false;
|
||||
},
|
||||
milliseconds: 5000,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user