implemented connectivity debouncing and refetch throttling for loadable state UI components
This commit is contained in:
@@ -62,8 +62,8 @@ class LoadableStateConsumer<
|
||||
|
||||
final showPrimaryLoading = isLoading && !hasContent;
|
||||
final showBackgroundLoading = isLoading && hasContent;
|
||||
final showError = hasError && !hasContent;
|
||||
final showErrorBar = hasError && hasContent;
|
||||
final showError = hasError && !hasContent && !isLoading;
|
||||
final showErrorBar = hasError && hasContent && !isLoading;
|
||||
|
||||
// Keep the wrapper hierarchy stable across refresh cycles: reFetch flips to
|
||||
// null mid-refetch, and toggling the RefreshIndicator on that signal would
|
||||
@@ -102,6 +102,7 @@ class LoadableStateConsumer<
|
||||
LoadableStateErrorBar(
|
||||
visible: showErrorBar,
|
||||
hasContent: hasContent,
|
||||
loading: isLoading,
|
||||
message: loadableState.error?.message,
|
||||
technicalDetails: loadableState.error?.technicalDetails,
|
||||
lastUpdated: loadableState.lastFetch,
|
||||
|
||||
@@ -5,16 +5,19 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../../widget/info_dialog.dart';
|
||||
import '../bloc/loadable_state_bloc.dart';
|
||||
import '../loadable_state_indicators.dart';
|
||||
|
||||
class LoadableStateErrorBar extends StatelessWidget {
|
||||
final bool visible;
|
||||
final bool hasContent;
|
||||
final bool loading;
|
||||
final String? message;
|
||||
final String? technicalDetails;
|
||||
final int? lastUpdated;
|
||||
const LoadableStateErrorBar({
|
||||
required this.visible,
|
||||
this.hasContent = false,
|
||||
this.loading = false,
|
||||
this.message,
|
||||
this.technicalDetails,
|
||||
this.lastUpdated,
|
||||
@@ -26,8 +29,12 @@ class LoadableStateErrorBar extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bloc = context.watch<LoadableStateBloc>();
|
||||
final isOfflineWithCache =
|
||||
hasContent && bloc.connectivityStatusKnown() && !bloc.isConnected();
|
||||
final isOfflineWithCache = shouldShowOfflineBar(
|
||||
hasContent: hasContent,
|
||||
loading: loading,
|
||||
connectivityKnown: bloc.connectivityStatusKnown(),
|
||||
connected: bloc.isConnected(),
|
||||
);
|
||||
final shouldShow = visible || isOfflineWithCache;
|
||||
|
||||
return AnimatedSize(
|
||||
|
||||
Reference in New Issue
Block a user