Skip to content

Commit 0638f80

Browse files
author
Kamil Klyta
committed
Better error message for the "refresh" method
1 parent e2d0e39 commit 0638f80

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/src/custom_refresh_indicator.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ class CustomRefreshIndicatorState extends State<CustomRefreshIndicator>
340340
throw StateError(
341341
"Cannot show indicator. "
342342
"Controller must be in the idle state. "
343-
"Current state: ${controller.state}.",
343+
"Current state: ${controller.state.name}.",
344344
);
345345
}
346346
setIndicatorState(IndicatorState.dragging);
@@ -357,6 +357,14 @@ class CustomRefreshIndicatorState extends State<CustomRefreshIndicator>
357357
Duration draggingDuration = const Duration(milliseconds: 300),
358358
Curve draggingCurve = Curves.linear,
359359
}) async {
360+
if (!controller.isIdle) {
361+
throw StateError(
362+
"Cannot refresh. "
363+
"Controller must be in the idle state. "
364+
"Current state: ${controller.state.name}.",
365+
);
366+
}
367+
360368
await show(
361369
draggingDuration: draggingDuration,
362370
draggingCurve: draggingCurve,

0 commit comments

Comments
 (0)