mirror of
https://github.com/chaos-zhu/easynode.git
synced 2026-10-06 15:13:18 +08:00
fix: server页下拉刷新
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user