Change material RefreshIndictor.onRefresh signature from Future<Null> to Future<void> (#18775) * Change material refresh indicator onRefresh signature from Future<Null> to Future<void>. * Update authors. * Explicitly name void argument.
diff --git a/AUTHORS b/AUTHORS index ab63cf6..c8e76db 100644 --- a/AUTHORS +++ b/AUTHORS
@@ -24,3 +24,4 @@ Dan Field <dfield@gmail.com> Noah Groß <gross@ngsger.de> Victor Choueiri <victor@ctrlanddev.com> +Lukasz Piliszczuk <lukasz@intheloup.io>
diff --git a/packages/flutter/lib/src/material/refresh_indicator.dart b/packages/flutter/lib/src/material/refresh_indicator.dart index 82bc036..265bf73 100644 --- a/packages/flutter/lib/src/material/refresh_indicator.dart +++ b/packages/flutter/lib/src/material/refresh_indicator.dart
@@ -32,7 +32,7 @@ /// finished. /// /// Used by [RefreshIndicator.onRefresh]. -typedef Future<Null> RefreshCallback(); +typedef Future<void> RefreshCallback(); // The state machine moves through these modes only when the scrollable // identified by scrollableKey has been scrolled to its min or max limit. @@ -146,7 +146,7 @@ Animation<Color> _valueColor; _RefreshIndicatorMode _mode; - Future<Null> _pendingRefreshFuture; + Future<void> _pendingRefreshFuture; bool _isIndicatorAtTop; double _dragOffset; @@ -297,7 +297,7 @@ } // Stop showing the refresh indicator. - Future<Null> _dismiss(_RefreshIndicatorMode newMode) async { + Future<void> _dismiss(_RefreshIndicatorMode newMode) async { // This can only be called from _show() when refreshing and // _handleScrollNotification in response to a ScrollEndNotification or // direction change. @@ -327,7 +327,7 @@ void _show() { assert(_mode != _RefreshIndicatorMode.refresh); assert(_mode != _RefreshIndicatorMode.snap); - final Completer<Null> completer = new Completer<Null>(); + final Completer<void> completer = new Completer<void>(); _pendingRefreshFuture = completer.future; _mode = _RefreshIndicatorMode.snap; _positionController @@ -340,7 +340,7 @@ _mode = _RefreshIndicatorMode.refresh; }); - final Future<Null> refreshResult = widget.onRefresh(); + final Future<void> refreshResult = widget.onRefresh(); assert(() { if (refreshResult == null) FlutterError.reportError(new FlutterErrorDetails( @@ -381,7 +381,7 @@ /// When initiated in this manner, the refresh indicator is independent of any /// actual scroll view. It defaults to showing the indicator at the top. To /// show it at the bottom, set `atTop` to false. - Future<Null> show({ bool atTop = true }) { + Future<void> show({ bool atTop = true }) { if (_mode != _RefreshIndicatorMode.refresh && _mode != _RefreshIndicatorMode.snap) { if (_mode == null)
diff --git a/packages/flutter/test/material/refresh_indicator_test.dart b/packages/flutter/test/material/refresh_indicator_test.dart index 841ef8a..ac58732 100644 --- a/packages/flutter/test/material/refresh_indicator_test.dart +++ b/packages/flutter/test/material/refresh_indicator_test.dart
@@ -10,14 +10,14 @@ bool refreshCalled = false; -Future<Null> refresh() { +Future<void> refresh() { refreshCalled = true; - return new Future<Null>.value(); + return new Future<void>.value(); } -Future<Null> holdRefresh() { +Future<void> holdRefresh() { refreshCalled = true; - return new Completer<Null>().future; + return new Completer<void>().future; } void main() { @@ -248,7 +248,7 @@ bool completed = false; tester.state<RefreshIndicatorState>(find.byType(RefreshIndicator)) .show() - .then<Null>((Null value) { completed = true; }); + .then<void>((void value) { completed = true; }); await tester.pump(); expect(completed, false); await tester.pump(const Duration(seconds: 1)); @@ -260,7 +260,7 @@ refreshCalled = false; tester.state<RefreshIndicatorState>(find.byType(RefreshIndicator)) .show() - .then<Null>((Null value) { completed = true; }); + .then<void>((void value) { completed = true; }); await tester.pump(); expect(completed, false); await tester.pump(const Duration(seconds: 1)); @@ -291,7 +291,7 @@ bool completed = false; tester.state<RefreshIndicatorState>(find.byType(RefreshIndicator)) .show() - .then<Null>((Null value) { completed = true; }); + .then<void>((void value) { completed = true; }); await tester.pump(); expect(completed, false); await tester.pump(const Duration(seconds: 1)); @@ -303,7 +303,7 @@ refreshCalled = false; tester.state<RefreshIndicatorState>(find.byType(RefreshIndicator)) .show() - .then<Null>((Null value) { completed = true; }); + .then<void>((void value) { completed = true; }); await tester.pump(); expect(completed, false); await tester.pump(const Duration(seconds: 1)); @@ -335,11 +335,11 @@ bool completed1 = false; tester.state<RefreshIndicatorState>(find.byType(RefreshIndicator)) .show() - .then<Null>((Null value) { completed1 = true; }); + .then<void>((void value) { completed1 = true; }); bool completed2 = false; tester.state<RefreshIndicatorState>(find.byType(RefreshIndicator)) .show() - .then<Null>((Null value) { completed2 = true; }); + .then<void>((void value) { completed2 = true; }); await tester.pump(); expect(completed1, false); expect(completed2, false);