fix: server页下拉刷新

This commit is contained in:
chaos-zhu
2026-05-20 21:59:08 +08:00
parent fbbbbd66be
commit 169e0905c5
2 changed files with 12 additions and 1 deletions
@@ -182,6 +182,11 @@ class _ServersTabState extends ConsumerState<ServersTab> {
],
),
body: RefreshIndicator(
color: Theme.of(context).colorScheme.primary,
backgroundColor: Theme.of(context).colorScheme.surface,
displacement: 30,
edgeOffset: 6,
strokeWidth: 2,
onRefresh: _refresh,
child: AnimatedBuilder(
animation: manager,
+7 -1
View File
@@ -21,7 +21,10 @@ class HostListNotifier extends AsyncNotifier<List<ServerModel>> {
}
Future<void> refresh() async {
state = const AsyncLoading();
final previous = state.valueOrNull;
if (previous == null) {
state = const AsyncLoading();
}
state = await AsyncValue.guard(() async {
try {
return await ref.read(serverRepositoryProvider).fetchHosts();
@@ -30,6 +33,9 @@ class HostListNotifier extends AsyncNotifier<List<ServerModel>> {
rethrow;
}
});
if (state.hasError && previous != null) {
state = AsyncData(previous);
}
}
}