Skip to content

Commit a5b3139

Browse files
mralepha-siva
authored andcommitted
Use void as type argument instead of Null where appropriate
1 parent 84580b5 commit a5b3139

19 files changed

+42
-42
lines changed

examples/stocks/lib/stock_settings.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class StockSettingsState extends State<StockSettings> {
8585
),
8686
]
8787
)
88-
).then<Null>(_handleOptimismChanged);
88+
).then<void>(_handleOptimismChanged);
8989
break;
9090
}
9191
}

packages/flutter/lib/src/gestures/long_press.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class LongPressGestureRecognizer extends PrimaryPointerGestureRecognizer {
2626
void didExceedDeadline() {
2727
resolve(GestureDisposition.accepted);
2828
if (onLongPress != null)
29-
invokeCallback<Null>('onLongPress', onLongPress); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
29+
invokeCallback<void>('onLongPress', onLongPress);
3030
}
3131

3232
@override

packages/flutter/lib/src/gestures/monodrag.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
120120
_pendingDragOffset = Offset.zero;
121121
_lastPendingEventTimestamp = event.timeStamp;
122122
if (onDown != null)
123-
invokeCallback<Null>('onDown', () => onDown(new DragDownDetails(globalPosition: _initialPosition))); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
123+
invokeCallback<void>('onDown', () => onDown(new DragDownDetails(globalPosition: _initialPosition)));
124124
} else if (_state == _DragState.accepted) {
125125
resolve(GestureDisposition.accepted);
126126
}
@@ -140,7 +140,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
140140
final Offset delta = event.delta;
141141
if (_state == _DragState.accepted) {
142142
if (onUpdate != null) {
143-
invokeCallback<Null>('onUpdate', () => onUpdate(new DragUpdateDetails( // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
143+
invokeCallback<void>('onUpdate', () => onUpdate(new DragUpdateDetails(
144144
sourceTimeStamp: event.timeStamp,
145145
delta: _getDeltaForDetails(delta),
146146
primaryDelta: _getPrimaryValueFromOffset(delta),
@@ -166,13 +166,13 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
166166
_pendingDragOffset = Offset.zero;
167167
_lastPendingEventTimestamp = null;
168168
if (onStart != null) {
169-
invokeCallback<Null>('onStart', () => onStart(new DragStartDetails( // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
169+
invokeCallback<void>('onStart', () => onStart(new DragStartDetails(
170170
sourceTimeStamp: timestamp,
171171
globalPosition: _initialPosition,
172172
)));
173173
}
174174
if (delta != Offset.zero && onUpdate != null) {
175-
invokeCallback<Null>('onUpdate', () => onUpdate(new DragUpdateDetails( // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
175+
invokeCallback<void>('onUpdate', () => onUpdate(new DragUpdateDetails(
176176
sourceTimeStamp: timestamp,
177177
delta: _getDeltaForDetails(delta),
178178
primaryDelta: _getPrimaryValueFromOffset(delta),
@@ -193,7 +193,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
193193
resolve(GestureDisposition.rejected);
194194
_state = _DragState.ready;
195195
if (onCancel != null)
196-
invokeCallback<Null>('onCancel', onCancel); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
196+
invokeCallback<void>('onCancel', onCancel);
197197
return;
198198
}
199199
final bool wasAccepted = (_state == _DragState.accepted);
@@ -206,14 +206,14 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
206206
if (estimate != null && _isFlingGesture(estimate)) {
207207
final Velocity velocity = new Velocity(pixelsPerSecond: estimate.pixelsPerSecond)
208208
.clampMagnitude(minFlingVelocity ?? kMinFlingVelocity, maxFlingVelocity ?? kMaxFlingVelocity);
209-
invokeCallback<Null>('onEnd', () => onEnd(new DragEndDetails( // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
209+
invokeCallback<void>('onEnd', () => onEnd(new DragEndDetails(
210210
velocity: velocity,
211211
primaryVelocity: _getPrimaryValueFromOffset(velocity.pixelsPerSecond),
212212
)), debugReport: () {
213213
return '$estimate; fling at $velocity.';
214214
});
215215
} else {
216-
invokeCallback<Null>('onEnd', () => onEnd(new DragEndDetails( // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
216+
invokeCallback<void>('onEnd', () => onEnd(new DragEndDetails(
217217
velocity: Velocity.zero,
218218
primaryVelocity: 0.0,
219219
)), debugReport: () {

packages/flutter/lib/src/gestures/multitap.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class DoubleTapGestureRecognizer extends GestureRecognizer {
194194
_freezeTracker(tracker);
195195
_trackers.remove(tracker.pointer);
196196
if (onDoubleTap != null)
197-
invokeCallback<Null>('onDoubleTap', onDoubleTap); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
197+
invokeCallback<void>('onDoubleTap', onDoubleTap);
198198
_reset();
199199
}
200200

@@ -353,7 +353,7 @@ class MultiTapGestureRecognizer extends GestureRecognizer {
353353
longTapDelay: longTapDelay
354354
);
355355
if (onTapDown != null)
356-
invokeCallback<Null>('onTapDown', () => onTapDown(event.pointer, new TapDownDetails(globalPosition: event.position))); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
356+
invokeCallback<void>('onTapDown', () => onTapDown(event.pointer, new TapDownDetails(globalPosition: event.position)));
357357
}
358358

359359
@override
@@ -373,22 +373,22 @@ class MultiTapGestureRecognizer extends GestureRecognizer {
373373
assert(_gestureMap.containsKey(pointer));
374374
_gestureMap.remove(pointer);
375375
if (onTapCancel != null)
376-
invokeCallback<Null>('onTapCancel', () => onTapCancel(pointer)); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
376+
invokeCallback<void>('onTapCancel', () => onTapCancel(pointer));
377377
}
378378

379379
void _dispatchTap(int pointer, Offset globalPosition) {
380380
assert(_gestureMap.containsKey(pointer));
381381
_gestureMap.remove(pointer);
382382
if (onTapUp != null)
383-
invokeCallback<Null>('onTapUp', () => onTapUp(pointer, new TapUpDetails(globalPosition: globalPosition))); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
383+
invokeCallback<void>('onTapUp', () => onTapUp(pointer, new TapUpDetails(globalPosition: globalPosition)));
384384
if (onTap != null)
385-
invokeCallback<Null>('onTap', () => onTap(pointer)); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
385+
invokeCallback<void>('onTap', () => onTap(pointer));
386386
}
387387

388388
void _dispatchLongTap(int pointer, Offset lastPosition) {
389389
assert(_gestureMap.containsKey(pointer));
390390
if (onLongTapDown != null)
391-
invokeCallback<Null>('onLongTapDown', () => onLongTapDown(pointer, new TapDownDetails(globalPosition: lastPosition))); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
391+
invokeCallback<void>('onLongTapDown', () => onLongTapDown(pointer, new TapDownDetails(globalPosition: lastPosition)));
392392
}
393393

394394
@override

packages/flutter/lib/src/gestures/scale.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
200200
final Offset pixelsPerSecond = velocity.pixelsPerSecond;
201201
if (pixelsPerSecond.distanceSquared > kMaxFlingVelocity * kMaxFlingVelocity)
202202
velocity = new Velocity(pixelsPerSecond: (pixelsPerSecond / pixelsPerSecond.distance) * kMaxFlingVelocity);
203-
invokeCallback<Null>('onEnd', () => onEnd(new ScaleEndDetails(velocity: velocity))); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
203+
invokeCallback<void>('onEnd', () => onEnd(new ScaleEndDetails(velocity: velocity)));
204204
} else {
205-
invokeCallback<Null>('onEnd', () => onEnd(new ScaleEndDetails(velocity: Velocity.zero))); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
205+
invokeCallback<void>('onEnd', () => onEnd(new ScaleEndDetails(velocity: Velocity.zero)));
206206
}
207207
}
208208
_state = _ScaleState.accepted;
@@ -230,13 +230,13 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
230230
}
231231

232232
if (_state == _ScaleState.started && onUpdate != null)
233-
invokeCallback<Null>('onUpdate', () => onUpdate(new ScaleUpdateDetails(scale: _scaleFactor, focalPoint: _currentFocalPoint))); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
233+
invokeCallback<void>('onUpdate', () => onUpdate(new ScaleUpdateDetails(scale: _scaleFactor, focalPoint: _currentFocalPoint)));
234234
}
235235

236236
void _dispatchOnStartCallbackIfNeeded() {
237237
assert(_state == _ScaleState.started);
238238
if (onStart != null)
239-
invokeCallback<Null>('onStart', () => onStart(new ScaleStartDetails(focalPoint: _currentFocalPoint))); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
239+
invokeCallback<void>('onStart', () => onStart(new ScaleStartDetails(focalPoint: _currentFocalPoint)));
240240
}
241241

242242
@override

packages/flutter/lib/src/gestures/tap.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer {
103103
// This can happen if the superclass decides the primary pointer
104104
// exceeded the touch slop, or if the recognizer is disposed.
105105
if (onTapCancel != null)
106-
invokeCallback<Null>('spontaneous onTapCancel', onTapCancel);
106+
invokeCallback<void>('spontaneous onTapCancel', onTapCancel);
107107
_reset();
108108
}
109109
super.resolve(disposition);
@@ -131,15 +131,15 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer {
131131
// Another gesture won the arena.
132132
assert(state != GestureRecognizerState.possible);
133133
if (onTapCancel != null)
134-
invokeCallback<Null>('forced onTapCancel', onTapCancel);
134+
invokeCallback<void>('forced onTapCancel', onTapCancel);
135135
_reset();
136136
}
137137
}
138138

139139
void _checkDown() {
140140
if (!_sentTapDown) {
141141
if (onTapDown != null)
142-
invokeCallback<Null>('onTapDown', () { onTapDown(new TapDownDetails(globalPosition: initialPosition)); });
142+
invokeCallback<void>('onTapDown', () { onTapDown(new TapDownDetails(globalPosition: initialPosition)); });
143143
_sentTapDown = true;
144144
}
145145
}
@@ -156,9 +156,9 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer {
156156
return;
157157
}
158158
if (onTapUp != null)
159-
invokeCallback<Null>('onTapUp', () { onTapUp(new TapUpDetails(globalPosition: _finalPosition)); });
159+
invokeCallback<void>('onTapUp', () { onTapUp(new TapUpDetails(globalPosition: _finalPosition)); });
160160
if (onTap != null)
161-
invokeCallback<Null>('onTap', onTap);
161+
invokeCallback<void>('onTap', onTap);
162162
_reset();
163163
}
164164
}

packages/flutter/lib/src/material/dropdown.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
578578
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
579579
);
580580

581-
Navigator.push(context, _dropdownRoute).then<Null>((_DropdownRouteResult<T> newValue) {
581+
Navigator.push(context, _dropdownRoute).then<void>((_DropdownRouteResult<T> newValue) {
582582
_dropdownRoute = null;
583583
if (!mounted || newValue == null)
584584
return null;

packages/flutter/lib/src/material/expansion_tile.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
120120
if (_isExpanded)
121121
_controller.forward();
122122
else
123-
_controller.reverse().then<Null>((Null value) {
123+
_controller.reverse().then<void>((Null value) {
124124
setState(() {
125125
// Rebuild without widget.children.
126126
});

packages/flutter/lib/src/material/popup_menu.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ class _PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
813813
initialValue: widget.initialValue,
814814
position: position,
815815
)
816-
.then<Null>((T newValue) {
816+
.then<void>((T newValue) {
817817
if (!mounted || newValue == null)
818818
return null;
819819
if (widget.onSelected != null)

packages/flutter/lib/src/material/refresh_indicator.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class RefreshIndicator extends StatefulWidget {
119119
/// The progress indicator's background color. The current theme's
120120
/// [ThemeData.canvasColor] by default.
121121
final Color backgroundColor;
122-
122+
123123
/// A check that specifies whether a [ScrollNotification] should be
124124
/// handled by this widget.
125125
///
@@ -322,7 +322,7 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
322322
_mode = _RefreshIndicatorMode.snap;
323323
_positionController
324324
.animateTo(1.0 / _kDragSizeFactorLimit, duration: _kIndicatorSnapDuration)
325-
.then<Null>((Null value) {
325+
.then<void>((Null value) {
326326
if (mounted && _mode == _RefreshIndicatorMode.snap) {
327327
assert(widget.onRefresh != null);
328328
setState(() {

packages/flutter/lib/src/material/scaffold.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ class Scaffold extends StatefulWidget {
369369
/// A panel displayed to the side of the [body], often hidden on mobile
370370
/// devices. Swipes in from either left-to-right ([TextDirection.ltr]) or
371371
/// right-to-left ([TextDirection.rtl])
372-
///
372+
///
373373
/// In the uncommon case that you wish to open the drawer manually, use the
374374
/// [ScaffoldState.openDrawer] function.
375375
///
@@ -678,7 +678,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
678678
if (_snackBars.isEmpty || _snackBarController.status == AnimationStatus.dismissed)
679679
return;
680680
final Completer<SnackBarClosedReason> completer = _snackBars.first._completer;
681-
_snackBarController.reverse().then<Null>((Null _) {
681+
_snackBarController.reverse().then<void>((Null _) {
682682
assert(mounted);
683683
if (!completer.isCompleted)
684684
completer.complete(reason);

packages/flutter/lib/src/painting/image_provider.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ abstract class ImageProvider<T> {
261261
assert(configuration != null);
262262
final ImageStream stream = new ImageStream();
263263
T obtainedKey;
264-
obtainKey(configuration).then<Null>((T key) {
264+
obtainKey(configuration).then<void>((T key) {
265265
obtainedKey = key;
266266
stream.setCompleter(PaintingBinding.instance.imageCache.putIfAbsent(key, () => load(key)));
267267
}).catchError(

packages/flutter/lib/src/painting/image_resolution.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class AssetImage extends AssetBundleImageProvider {
166166
final AssetBundle chosenBundle = bundle ?? configuration.bundle ?? rootBundle;
167167
Completer<AssetBundleImageKey> completer;
168168
Future<AssetBundleImageKey> result;
169-
chosenBundle.loadStructuredData<Map<String, List<String>>>(_kAssetManifestFileName, _manifestParser).then<Null>(
169+
chosenBundle.loadStructuredData<Map<String, List<String>>>(_kAssetManifestFileName, _manifestParser).then<void>(
170170
(Map<String, List<String>> manifest) {
171171
final String chosenName = _chooseVariant(
172172
keyName,

packages/flutter/lib/src/painting/image_stream.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class OneFrameImageStreamCompleter extends ImageStreamCompleter {
270270
/// FlutterErrorDetails]).
271271
OneFrameImageStreamCompleter(Future<ImageInfo> image, { InformationCollector informationCollector })
272272
: assert(image != null) {
273-
image.then<Null>(setImage, onError: (dynamic error, StackTrace stack) {
273+
image.then<void>(setImage, onError: (dynamic error, StackTrace stack) {
274274
FlutterError.reportError(new FlutterErrorDetails(
275275
exception: error,
276276
stack: stack,
@@ -333,7 +333,7 @@ class MultiFrameImageStreamCompleter extends ImageStreamCompleter {
333333
_scale = scale,
334334
_framesEmitted = 0,
335335
_timer = null {
336-
codec.then<Null>(_handleCodecReady, onError: (dynamic error, StackTrace stack) {
336+
codec.then<void>(_handleCodecReady, onError: (dynamic error, StackTrace stack) {
337337
FlutterError.reportError(new FlutterErrorDetails(
338338
exception: error,
339339
stack: stack,

packages/flutter/lib/src/services/asset_bundle.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ abstract class CachingAssetBundle extends AssetBundle {
181181
return _structuredDataCache[key];
182182
Completer<T> completer;
183183
Future<T> result;
184-
loadString(key, cache: false).then<T>(parser).then<Null>((T value) {
184+
loadString(key, cache: false).then<T>(parser).then<void>((T value) {
185185
result = new SynchronousFuture<T>(value);
186186
_structuredDataCache[key] = result;
187187
if (completer != null) {

packages/flutter/lib/src/widgets/animated_list.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ class AnimatedListState extends State<AnimatedList> with TickerProviderStateMixi
298298
_itemsCount += 1;
299299
});
300300

301-
controller.forward().then<Null>((Null value) {
301+
controller.forward().then<void>((Null value) {
302302
_removeActiveItemAt(_incomingItems, incomingItem.itemIndex).controller.dispose();
303303
});
304304
}
@@ -333,7 +333,7 @@ class AnimatedListState extends State<AnimatedList> with TickerProviderStateMixi
333333
..sort();
334334
});
335335

336-
controller.reverse().then<Null>((Null value) {
336+
controller.reverse().then<void>((Null value) {
337337
_removeActiveItemAt(_outgoingItems, outgoingItem.itemIndex).controller.dispose();
338338

339339
// Decrement the incoming and outgoing item indices to account

packages/flutter/lib/src/widgets/async.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ class _FutureBuilderState<T> extends State<FutureBuilder<T>> {
513513
if (widget.future != null) {
514514
final Object callbackIdentity = new Object();
515515
_activeCallbackIdentity = callbackIdentity;
516-
widget.future.then<Null>((T data) {
516+
widget.future.then<void>((T data) {
517517
if (_activeCallbackIdentity == callbackIdentity) {
518518
setState(() {
519519
_snapshot = new AsyncSnapshot<T>.withData(ConnectionState.done, data);

packages/flutter/test/foundation/capture_output.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'dart:ui' show VoidCallback;
88
List<String> captureOutput(VoidCallback fn) {
99
final List<String> log = <String>[];
1010

11-
runZoned<Null>(fn, zoneSpecification: new ZoneSpecification(
11+
runZoned<void>(fn, zoneSpecification: new ZoneSpecification(
1212
print: (Zone self,
1313
ZoneDelegate parent,
1414
Zone zone,

packages/flutter/test/widgets/image_resolution_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class TestAssetBundle extends CachingAssetBundle {
9090

9191
class FakeImageStreamCompleter extends ImageStreamCompleter {
9292
FakeImageStreamCompleter(Future<ImageInfo> image) {
93-
image.then<Null>(setImage);
93+
image.then<void>(setImage);
9494
}
9595
}
9696

@@ -100,7 +100,7 @@ class TestAssetImage extends AssetImage {
100100
@override
101101
ImageStreamCompleter load(AssetBundleImageKey key) {
102102
ImageInfo imageInfo;
103-
key.bundle.load(key.name).then<Null>((ByteData data) {
103+
key.bundle.load(key.name).then<void>((ByteData data) {
104104
final TestByteData testData = data;
105105
final ui.Image image = new TestImage(testData.scale);
106106
imageInfo = new ImageInfo(image: image, scale: key.scale);

0 commit comments

Comments
 (0)