Use void as type argument instead of Null where appropriate
This commit is contained in:
@@ -85,7 +85,7 @@ class StockSettingsState extends State<StockSettings> {
|
||||
),
|
||||
]
|
||||
)
|
||||
).then<Null>(_handleOptimismChanged);
|
||||
).then<void>(_handleOptimismChanged);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class LongPressGestureRecognizer extends PrimaryPointerGestureRecognizer {
|
||||
void didExceedDeadline() {
|
||||
resolve(GestureDisposition.accepted);
|
||||
if (onLongPress != null)
|
||||
invokeCallback<Null>('onLongPress', onLongPress); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
|
||||
invokeCallback<void>('onLongPress', onLongPress);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -120,7 +120,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
|
||||
_pendingDragOffset = Offset.zero;
|
||||
_lastPendingEventTimestamp = event.timeStamp;
|
||||
if (onDown != null)
|
||||
invokeCallback<Null>('onDown', () => onDown(new DragDownDetails(globalPosition: _initialPosition))); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
|
||||
invokeCallback<void>('onDown', () => onDown(new DragDownDetails(globalPosition: _initialPosition)));
|
||||
} else if (_state == _DragState.accepted) {
|
||||
resolve(GestureDisposition.accepted);
|
||||
}
|
||||
@@ -140,7 +140,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
|
||||
final Offset delta = event.delta;
|
||||
if (_state == _DragState.accepted) {
|
||||
if (onUpdate != null) {
|
||||
invokeCallback<Null>('onUpdate', () => onUpdate(new DragUpdateDetails( // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
|
||||
invokeCallback<void>('onUpdate', () => onUpdate(new DragUpdateDetails(
|
||||
sourceTimeStamp: event.timeStamp,
|
||||
delta: _getDeltaForDetails(delta),
|
||||
primaryDelta: _getPrimaryValueFromOffset(delta),
|
||||
@@ -166,13 +166,13 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
|
||||
_pendingDragOffset = Offset.zero;
|
||||
_lastPendingEventTimestamp = null;
|
||||
if (onStart != null) {
|
||||
invokeCallback<Null>('onStart', () => onStart(new DragStartDetails( // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
|
||||
invokeCallback<void>('onStart', () => onStart(new DragStartDetails(
|
||||
sourceTimeStamp: timestamp,
|
||||
globalPosition: _initialPosition,
|
||||
)));
|
||||
}
|
||||
if (delta != Offset.zero && onUpdate != null) {
|
||||
invokeCallback<Null>('onUpdate', () => onUpdate(new DragUpdateDetails( // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
|
||||
invokeCallback<void>('onUpdate', () => onUpdate(new DragUpdateDetails(
|
||||
sourceTimeStamp: timestamp,
|
||||
delta: _getDeltaForDetails(delta),
|
||||
primaryDelta: _getPrimaryValueFromOffset(delta),
|
||||
@@ -193,7 +193,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
|
||||
resolve(GestureDisposition.rejected);
|
||||
_state = _DragState.ready;
|
||||
if (onCancel != null)
|
||||
invokeCallback<Null>('onCancel', onCancel); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
|
||||
invokeCallback<void>('onCancel', onCancel);
|
||||
return;
|
||||
}
|
||||
final bool wasAccepted = (_state == _DragState.accepted);
|
||||
@@ -206,14 +206,14 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
|
||||
if (estimate != null && _isFlingGesture(estimate)) {
|
||||
final Velocity velocity = new Velocity(pixelsPerSecond: estimate.pixelsPerSecond)
|
||||
.clampMagnitude(minFlingVelocity ?? kMinFlingVelocity, maxFlingVelocity ?? kMaxFlingVelocity);
|
||||
invokeCallback<Null>('onEnd', () => onEnd(new DragEndDetails( // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
|
||||
invokeCallback<void>('onEnd', () => onEnd(new DragEndDetails(
|
||||
velocity: velocity,
|
||||
primaryVelocity: _getPrimaryValueFromOffset(velocity.pixelsPerSecond),
|
||||
)), debugReport: () {
|
||||
return '$estimate; fling at $velocity.';
|
||||
});
|
||||
} else {
|
||||
invokeCallback<Null>('onEnd', () => onEnd(new DragEndDetails( // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
|
||||
invokeCallback<void>('onEnd', () => onEnd(new DragEndDetails(
|
||||
velocity: Velocity.zero,
|
||||
primaryVelocity: 0.0,
|
||||
)), debugReport: () {
|
||||
|
||||
@@ -194,7 +194,7 @@ class DoubleTapGestureRecognizer extends GestureRecognizer {
|
||||
_freezeTracker(tracker);
|
||||
_trackers.remove(tracker.pointer);
|
||||
if (onDoubleTap != null)
|
||||
invokeCallback<Null>('onDoubleTap', onDoubleTap); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
|
||||
invokeCallback<void>('onDoubleTap', onDoubleTap);
|
||||
_reset();
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ class MultiTapGestureRecognizer extends GestureRecognizer {
|
||||
longTapDelay: longTapDelay
|
||||
);
|
||||
if (onTapDown != null)
|
||||
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
|
||||
invokeCallback<void>('onTapDown', () => onTapDown(event.pointer, new TapDownDetails(globalPosition: event.position)));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -373,22 +373,22 @@ class MultiTapGestureRecognizer extends GestureRecognizer {
|
||||
assert(_gestureMap.containsKey(pointer));
|
||||
_gestureMap.remove(pointer);
|
||||
if (onTapCancel != null)
|
||||
invokeCallback<Null>('onTapCancel', () => onTapCancel(pointer)); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
|
||||
invokeCallback<void>('onTapCancel', () => onTapCancel(pointer));
|
||||
}
|
||||
|
||||
void _dispatchTap(int pointer, Offset globalPosition) {
|
||||
assert(_gestureMap.containsKey(pointer));
|
||||
_gestureMap.remove(pointer);
|
||||
if (onTapUp != null)
|
||||
invokeCallback<Null>('onTapUp', () => onTapUp(pointer, new TapUpDetails(globalPosition: globalPosition))); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
|
||||
invokeCallback<void>('onTapUp', () => onTapUp(pointer, new TapUpDetails(globalPosition: globalPosition)));
|
||||
if (onTap != null)
|
||||
invokeCallback<Null>('onTap', () => onTap(pointer)); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
|
||||
invokeCallback<void>('onTap', () => onTap(pointer));
|
||||
}
|
||||
|
||||
void _dispatchLongTap(int pointer, Offset lastPosition) {
|
||||
assert(_gestureMap.containsKey(pointer));
|
||||
if (onLongTapDown != null)
|
||||
invokeCallback<Null>('onLongTapDown', () => onLongTapDown(pointer, new TapDownDetails(globalPosition: lastPosition))); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
|
||||
invokeCallback<void>('onLongTapDown', () => onLongTapDown(pointer, new TapDownDetails(globalPosition: lastPosition)));
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -200,9 +200,9 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
|
||||
final Offset pixelsPerSecond = velocity.pixelsPerSecond;
|
||||
if (pixelsPerSecond.distanceSquared > kMaxFlingVelocity * kMaxFlingVelocity)
|
||||
velocity = new Velocity(pixelsPerSecond: (pixelsPerSecond / pixelsPerSecond.distance) * kMaxFlingVelocity);
|
||||
invokeCallback<Null>('onEnd', () => onEnd(new ScaleEndDetails(velocity: velocity))); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
|
||||
invokeCallback<void>('onEnd', () => onEnd(new ScaleEndDetails(velocity: velocity)));
|
||||
} else {
|
||||
invokeCallback<Null>('onEnd', () => onEnd(new ScaleEndDetails(velocity: Velocity.zero))); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
|
||||
invokeCallback<void>('onEnd', () => onEnd(new ScaleEndDetails(velocity: Velocity.zero)));
|
||||
}
|
||||
}
|
||||
_state = _ScaleState.accepted;
|
||||
@@ -230,13 +230,13 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
|
||||
}
|
||||
|
||||
if (_state == _ScaleState.started && onUpdate != null)
|
||||
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
|
||||
invokeCallback<void>('onUpdate', () => onUpdate(new ScaleUpdateDetails(scale: _scaleFactor, focalPoint: _currentFocalPoint)));
|
||||
}
|
||||
|
||||
void _dispatchOnStartCallbackIfNeeded() {
|
||||
assert(_state == _ScaleState.started);
|
||||
if (onStart != null)
|
||||
invokeCallback<Null>('onStart', () => onStart(new ScaleStartDetails(focalPoint: _currentFocalPoint))); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27504
|
||||
invokeCallback<void>('onStart', () => onStart(new ScaleStartDetails(focalPoint: _currentFocalPoint)));
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -103,7 +103,7 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer {
|
||||
// This can happen if the superclass decides the primary pointer
|
||||
// exceeded the touch slop, or if the recognizer is disposed.
|
||||
if (onTapCancel != null)
|
||||
invokeCallback<Null>('spontaneous onTapCancel', onTapCancel);
|
||||
invokeCallback<void>('spontaneous onTapCancel', onTapCancel);
|
||||
_reset();
|
||||
}
|
||||
super.resolve(disposition);
|
||||
@@ -131,7 +131,7 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer {
|
||||
// Another gesture won the arena.
|
||||
assert(state != GestureRecognizerState.possible);
|
||||
if (onTapCancel != null)
|
||||
invokeCallback<Null>('forced onTapCancel', onTapCancel);
|
||||
invokeCallback<void>('forced onTapCancel', onTapCancel);
|
||||
_reset();
|
||||
}
|
||||
}
|
||||
@@ -139,7 +139,7 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer {
|
||||
void _checkDown() {
|
||||
if (!_sentTapDown) {
|
||||
if (onTapDown != null)
|
||||
invokeCallback<Null>('onTapDown', () { onTapDown(new TapDownDetails(globalPosition: initialPosition)); });
|
||||
invokeCallback<void>('onTapDown', () { onTapDown(new TapDownDetails(globalPosition: initialPosition)); });
|
||||
_sentTapDown = true;
|
||||
}
|
||||
}
|
||||
@@ -156,9 +156,9 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer {
|
||||
return;
|
||||
}
|
||||
if (onTapUp != null)
|
||||
invokeCallback<Null>('onTapUp', () { onTapUp(new TapUpDetails(globalPosition: _finalPosition)); });
|
||||
invokeCallback<void>('onTapUp', () { onTapUp(new TapUpDetails(globalPosition: _finalPosition)); });
|
||||
if (onTap != null)
|
||||
invokeCallback<Null>('onTap', onTap);
|
||||
invokeCallback<void>('onTap', onTap);
|
||||
_reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -578,7 +578,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
|
||||
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
|
||||
);
|
||||
|
||||
Navigator.push(context, _dropdownRoute).then<Null>((_DropdownRouteResult<T> newValue) {
|
||||
Navigator.push(context, _dropdownRoute).then<void>((_DropdownRouteResult<T> newValue) {
|
||||
_dropdownRoute = null;
|
||||
if (!mounted || newValue == null)
|
||||
return null;
|
||||
|
||||
@@ -120,7 +120,7 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
|
||||
if (_isExpanded)
|
||||
_controller.forward();
|
||||
else
|
||||
_controller.reverse().then<Null>((Null value) {
|
||||
_controller.reverse().then<void>((Null value) {
|
||||
setState(() {
|
||||
// Rebuild without widget.children.
|
||||
});
|
||||
|
||||
@@ -813,7 +813,7 @@ class _PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
|
||||
initialValue: widget.initialValue,
|
||||
position: position,
|
||||
)
|
||||
.then<Null>((T newValue) {
|
||||
.then<void>((T newValue) {
|
||||
if (!mounted || newValue == null)
|
||||
return null;
|
||||
if (widget.onSelected != null)
|
||||
|
||||
@@ -119,7 +119,7 @@ class RefreshIndicator extends StatefulWidget {
|
||||
/// The progress indicator's background color. The current theme's
|
||||
/// [ThemeData.canvasColor] by default.
|
||||
final Color backgroundColor;
|
||||
|
||||
|
||||
/// A check that specifies whether a [ScrollNotification] should be
|
||||
/// handled by this widget.
|
||||
///
|
||||
@@ -322,7 +322,7 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
|
||||
_mode = _RefreshIndicatorMode.snap;
|
||||
_positionController
|
||||
.animateTo(1.0 / _kDragSizeFactorLimit, duration: _kIndicatorSnapDuration)
|
||||
.then<Null>((Null value) {
|
||||
.then<void>((Null value) {
|
||||
if (mounted && _mode == _RefreshIndicatorMode.snap) {
|
||||
assert(widget.onRefresh != null);
|
||||
setState(() {
|
||||
|
||||
@@ -369,7 +369,7 @@ class Scaffold extends StatefulWidget {
|
||||
/// A panel displayed to the side of the [body], often hidden on mobile
|
||||
/// devices. Swipes in from either left-to-right ([TextDirection.ltr]) or
|
||||
/// right-to-left ([TextDirection.rtl])
|
||||
///
|
||||
///
|
||||
/// In the uncommon case that you wish to open the drawer manually, use the
|
||||
/// [ScaffoldState.openDrawer] function.
|
||||
///
|
||||
@@ -678,7 +678,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
|
||||
if (_snackBars.isEmpty || _snackBarController.status == AnimationStatus.dismissed)
|
||||
return;
|
||||
final Completer<SnackBarClosedReason> completer = _snackBars.first._completer;
|
||||
_snackBarController.reverse().then<Null>((Null _) {
|
||||
_snackBarController.reverse().then<void>((Null _) {
|
||||
assert(mounted);
|
||||
if (!completer.isCompleted)
|
||||
completer.complete(reason);
|
||||
|
||||
@@ -261,7 +261,7 @@ abstract class ImageProvider<T> {
|
||||
assert(configuration != null);
|
||||
final ImageStream stream = new ImageStream();
|
||||
T obtainedKey;
|
||||
obtainKey(configuration).then<Null>((T key) {
|
||||
obtainKey(configuration).then<void>((T key) {
|
||||
obtainedKey = key;
|
||||
stream.setCompleter(PaintingBinding.instance.imageCache.putIfAbsent(key, () => load(key)));
|
||||
}).catchError(
|
||||
|
||||
@@ -166,7 +166,7 @@ class AssetImage extends AssetBundleImageProvider {
|
||||
final AssetBundle chosenBundle = bundle ?? configuration.bundle ?? rootBundle;
|
||||
Completer<AssetBundleImageKey> completer;
|
||||
Future<AssetBundleImageKey> result;
|
||||
chosenBundle.loadStructuredData<Map<String, List<String>>>(_kAssetManifestFileName, _manifestParser).then<Null>(
|
||||
chosenBundle.loadStructuredData<Map<String, List<String>>>(_kAssetManifestFileName, _manifestParser).then<void>(
|
||||
(Map<String, List<String>> manifest) {
|
||||
final String chosenName = _chooseVariant(
|
||||
keyName,
|
||||
|
||||
@@ -270,7 +270,7 @@ class OneFrameImageStreamCompleter extends ImageStreamCompleter {
|
||||
/// FlutterErrorDetails]).
|
||||
OneFrameImageStreamCompleter(Future<ImageInfo> image, { InformationCollector informationCollector })
|
||||
: assert(image != null) {
|
||||
image.then<Null>(setImage, onError: (dynamic error, StackTrace stack) {
|
||||
image.then<void>(setImage, onError: (dynamic error, StackTrace stack) {
|
||||
FlutterError.reportError(new FlutterErrorDetails(
|
||||
exception: error,
|
||||
stack: stack,
|
||||
@@ -333,7 +333,7 @@ class MultiFrameImageStreamCompleter extends ImageStreamCompleter {
|
||||
_scale = scale,
|
||||
_framesEmitted = 0,
|
||||
_timer = null {
|
||||
codec.then<Null>(_handleCodecReady, onError: (dynamic error, StackTrace stack) {
|
||||
codec.then<void>(_handleCodecReady, onError: (dynamic error, StackTrace stack) {
|
||||
FlutterError.reportError(new FlutterErrorDetails(
|
||||
exception: error,
|
||||
stack: stack,
|
||||
|
||||
@@ -181,7 +181,7 @@ abstract class CachingAssetBundle extends AssetBundle {
|
||||
return _structuredDataCache[key];
|
||||
Completer<T> completer;
|
||||
Future<T> result;
|
||||
loadString(key, cache: false).then<T>(parser).then<Null>((T value) {
|
||||
loadString(key, cache: false).then<T>(parser).then<void>((T value) {
|
||||
result = new SynchronousFuture<T>(value);
|
||||
_structuredDataCache[key] = result;
|
||||
if (completer != null) {
|
||||
|
||||
@@ -298,7 +298,7 @@ class AnimatedListState extends State<AnimatedList> with TickerProviderStateMixi
|
||||
_itemsCount += 1;
|
||||
});
|
||||
|
||||
controller.forward().then<Null>((Null value) {
|
||||
controller.forward().then<void>((Null value) {
|
||||
_removeActiveItemAt(_incomingItems, incomingItem.itemIndex).controller.dispose();
|
||||
});
|
||||
}
|
||||
@@ -333,7 +333,7 @@ class AnimatedListState extends State<AnimatedList> with TickerProviderStateMixi
|
||||
..sort();
|
||||
});
|
||||
|
||||
controller.reverse().then<Null>((Null value) {
|
||||
controller.reverse().then<void>((Null value) {
|
||||
_removeActiveItemAt(_outgoingItems, outgoingItem.itemIndex).controller.dispose();
|
||||
|
||||
// Decrement the incoming and outgoing item indices to account
|
||||
|
||||
@@ -513,7 +513,7 @@ class _FutureBuilderState<T> extends State<FutureBuilder<T>> {
|
||||
if (widget.future != null) {
|
||||
final Object callbackIdentity = new Object();
|
||||
_activeCallbackIdentity = callbackIdentity;
|
||||
widget.future.then<Null>((T data) {
|
||||
widget.future.then<void>((T data) {
|
||||
if (_activeCallbackIdentity == callbackIdentity) {
|
||||
setState(() {
|
||||
_snapshot = new AsyncSnapshot<T>.withData(ConnectionState.done, data);
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'dart:ui' show VoidCallback;
|
||||
List<String> captureOutput(VoidCallback fn) {
|
||||
final List<String> log = <String>[];
|
||||
|
||||
runZoned<Null>(fn, zoneSpecification: new ZoneSpecification(
|
||||
runZoned<void>(fn, zoneSpecification: new ZoneSpecification(
|
||||
print: (Zone self,
|
||||
ZoneDelegate parent,
|
||||
Zone zone,
|
||||
|
||||
@@ -90,7 +90,7 @@ class TestAssetBundle extends CachingAssetBundle {
|
||||
|
||||
class FakeImageStreamCompleter extends ImageStreamCompleter {
|
||||
FakeImageStreamCompleter(Future<ImageInfo> image) {
|
||||
image.then<Null>(setImage);
|
||||
image.then<void>(setImage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ class TestAssetImage extends AssetImage {
|
||||
@override
|
||||
ImageStreamCompleter load(AssetBundleImageKey key) {
|
||||
ImageInfo imageInfo;
|
||||
key.bundle.load(key.name).then<Null>((ByteData data) {
|
||||
key.bundle.load(key.name).then<void>((ByteData data) {
|
||||
final TestByteData testData = data;
|
||||
final ui.Image image = new TestImage(testData.scale);
|
||||
imageInfo = new ImageInfo(image: image, scale: key.scale);
|
||||
|
||||
Reference in New Issue
Block a user