Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions lib/declarative_refresh_indicator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,21 @@ class _DeclarativeRefreshIndicatorState
super.initState();
// If the indicator should be shown initially, show it.
WidgetsBinding.instance!.addPostFrameCallback((_) {
if (widget.refreshing) _show();
if (widget.refreshing && !_showing)
_show();
else if (!widget.refreshing && _showing) _hide();
});
}

@override
void didUpdateWidget(DeclarativeRefreshIndicator oldWidget) {
super.didUpdateWidget(oldWidget);
// If the [refreshing] field has not changed, do nothing.
if (oldWidget.refreshing == widget.refreshing) return;
// Otherwise, update the indicator accordingly.
super.didUpdateWidget(oldWidget);
if (widget.refreshing) {
// The indicator may have been shown already, if it was shown
// interactively. If it hasn't, show it now.
if (!_showing) _show();
} else {
_hide();
if (_showing) _hide();
}
}

Expand All @@ -162,7 +161,7 @@ class _DeclarativeRefreshIndicatorState
// The completer should not exist at this point.
// It's created here, and must complete before this callback can be
// called again.
assert(_completer == null);
assert(_completer == null, 'The completer should not exist');

// Create the completer and use it.
final completer = Completer<void>();
Expand Down