mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
unnecessary null comparison (#67525)
This commit is contained in:
parent
0b78110b26
commit
0d8d4f77aa
@ -378,7 +378,10 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
|
||||
));
|
||||
return true;
|
||||
}());
|
||||
if (refreshResult == null)
|
||||
// `refreshResult` has a non-nullable type, but might be null when
|
||||
// running with weak checking, so we need to null check it anyway (and
|
||||
// ignore the warning that the null-handling logic is dead code).
|
||||
if (refreshResult == null) // ignore: dead_code
|
||||
return;
|
||||
refreshResult.whenComplete(() {
|
||||
if (mounted && _mode == _RefreshIndicatorMode.refresh) {
|
||||
|
||||
@ -3326,38 +3326,28 @@ class _StandardBottomSheetState extends State<_StandardBottomSheet> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.animationController != null) {
|
||||
return AnimatedBuilder(
|
||||
animation: widget.animationController,
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
return Align(
|
||||
alignment: AlignmentDirectional.topStart,
|
||||
heightFactor: animationCurve.transform(widget.animationController.value),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: _wrapBottomSheet(
|
||||
BottomSheet(
|
||||
animationController: widget.animationController,
|
||||
enableDrag: widget.enableDrag,
|
||||
onDragStart: _handleDragStart,
|
||||
onDragEnd: _handleDragEnd,
|
||||
onClosing: widget.onClosing!,
|
||||
builder: widget.builder,
|
||||
backgroundColor: widget.backgroundColor,
|
||||
elevation: widget.elevation,
|
||||
shape: widget.shape,
|
||||
clipBehavior: widget.clipBehavior,
|
||||
),
|
||||
return AnimatedBuilder(
|
||||
animation: widget.animationController,
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
return Align(
|
||||
alignment: AlignmentDirectional.topStart,
|
||||
heightFactor: animationCurve.transform(widget.animationController.value),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: _wrapBottomSheet(
|
||||
BottomSheet(
|
||||
animationController: widget.animationController,
|
||||
enableDrag: widget.enableDrag,
|
||||
onDragStart: _handleDragStart,
|
||||
onDragEnd: _handleDragEnd,
|
||||
onClosing: widget.onClosing!,
|
||||
builder: widget.builder,
|
||||
backgroundColor: widget.backgroundColor,
|
||||
elevation: widget.elevation,
|
||||
shape: widget.shape,
|
||||
clipBehavior: widget.clipBehavior,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return _wrapBottomSheet(
|
||||
BottomSheet(
|
||||
onClosing: widget.onClosing!,
|
||||
builder: widget.builder,
|
||||
backgroundColor: widget.backgroundColor,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ import 'package:flutter/foundation.dart';
|
||||
import 'binding.dart';
|
||||
|
||||
/// A function which takes a platform message and asynchronously returns an encoded response.
|
||||
typedef MessageHandler = Future<ByteData?> Function(ByteData? message);
|
||||
typedef MessageHandler = Future<ByteData?>? Function(ByteData? message);
|
||||
|
||||
/// A messenger which sends binary data across the Flutter platform barrier.
|
||||
///
|
||||
@ -31,7 +31,7 @@ abstract class BinaryMessenger {
|
||||
///
|
||||
/// Returns a [Future] which completes to the received response, undecoded,
|
||||
/// in binary form.
|
||||
Future<ByteData?> send(String channel, ByteData? message);
|
||||
Future<ByteData?>? send(String channel, ByteData? message);
|
||||
|
||||
/// Set a callback for receiving messages from the platform plugins on the
|
||||
/// given channel, without decoding them.
|
||||
|
||||
@ -300,7 +300,7 @@ class _DefaultBinaryMessenger extends BinaryMessenger {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ByteData?> send(String channel, ByteData? message) {
|
||||
Future<ByteData?>? send(String channel, ByteData? message) {
|
||||
final MessageHandler? handler = _mockHandlers[channel];
|
||||
if (handler != null)
|
||||
return handler(message);
|
||||
|
||||
@ -65,7 +65,7 @@ class BinaryMessages {
|
||||
'Use defaultBinaryMessenger.send instead. '
|
||||
'This feature was deprecated after v1.6.5.'
|
||||
)
|
||||
static Future<ByteData?> send(String channel, ByteData? message) {
|
||||
static Future<ByteData?>? send(String channel, ByteData? message) {
|
||||
return _binaryMessenger.send(channel, message);
|
||||
}
|
||||
|
||||
|
||||
@ -821,10 +821,6 @@ class _TestRecordingCanvasPatternMatcher extends _TestRecordingCanvasMatcher imp
|
||||
final Iterator<RecordedInvocation> call = calls.iterator..moveNext();
|
||||
try {
|
||||
while (predicate.moveNext()) {
|
||||
if (call.current == null) {
|
||||
throw 'It painted less on its canvas than the paint pattern expected. '
|
||||
'The first missing paint call was: ${predicate.current}';
|
||||
}
|
||||
predicate.current.match(call);
|
||||
}
|
||||
assert(predicate.current == null);
|
||||
@ -836,11 +832,7 @@ class _TestRecordingCanvasPatternMatcher extends _TestRecordingCanvasMatcher imp
|
||||
return false;
|
||||
} on String catch (s) {
|
||||
description.writeln(s);
|
||||
if (call.current != null) {
|
||||
description.write('The stack of the offending call was:\n${call.current.stackToString(indent: " ")}\n');
|
||||
} else {
|
||||
description.write('The stack of the first call was:\n${calls.first.stackToString(indent: " ")}\n');
|
||||
}
|
||||
description.write('The stack of the offending call was:\n${call.current.stackToString(indent: " ")}\n');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -1390,8 +1382,6 @@ class _SomethingPaintPredicate extends _PaintPredicate {
|
||||
RecordedInvocation currentCall;
|
||||
do {
|
||||
currentCall = call.current;
|
||||
if (currentCall == null)
|
||||
throw 'It did not call anything that was matched by the predicate passed to a "something" step of the paint pattern.';
|
||||
if (!currentCall.invocation.isMethod)
|
||||
throw 'It called $currentCall, which was not a method, when the paint pattern expected a method call';
|
||||
call.moveNext();
|
||||
|
||||
@ -42,8 +42,7 @@ DriverError _createInvalidKeyValueTypeError(String invalidType) {
|
||||
abstract class CommandWithTarget extends Command {
|
||||
/// Constructs this command given a [finder].
|
||||
CommandWithTarget(this.finder, {Duration timeout}) : super(timeout: timeout) {
|
||||
if (finder == null)
|
||||
throw DriverError('$runtimeType target cannot be null');
|
||||
assert(finder != null, '$runtimeType target cannot be null');
|
||||
}
|
||||
|
||||
/// Deserializes this command from the value generated by [serialize].
|
||||
|
||||
@ -164,13 +164,7 @@ class _InternalCombinedCondition implements WaitCondition {
|
||||
if (condition.conditionName != 'CombinedCondition')
|
||||
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
|
||||
final CombinedCondition combinedCondition = condition as CombinedCondition;
|
||||
if (combinedCondition.conditions == null) {
|
||||
return const _InternalCombinedCondition(<WaitCondition>[]);
|
||||
}
|
||||
|
||||
final List<WaitCondition> conditions = combinedCondition.conditions.map(
|
||||
(SerializableWaitCondition serializableCondition) => deserializeCondition(serializableCondition)
|
||||
).toList();
|
||||
final List<WaitCondition> conditions = combinedCondition.conditions.map(deserializeCondition).toList();
|
||||
return _InternalCombinedCondition(conditions);
|
||||
}
|
||||
|
||||
|
||||
@ -101,11 +101,11 @@ class TestDefaultBinaryMessenger extends BinaryMessenger {
|
||||
int get pendingMessageCount => _pendingMessages.length;
|
||||
|
||||
@override
|
||||
Future<ByteData?> send(String channel, ByteData? message) {
|
||||
final Future<ByteData?> resultFuture = delegate.send(channel, message);
|
||||
// Removes the future itself from the [_pendingMessages] list when it
|
||||
// completes.
|
||||
Future<ByteData?>? send(String channel, ByteData? message) {
|
||||
final Future<ByteData?>? resultFuture = delegate.send(channel, message);
|
||||
if (resultFuture != null) {
|
||||
// Removes the future itself from the [_pendingMessages] list when it
|
||||
// completes.
|
||||
_pendingMessages.add(resultFuture);
|
||||
resultFuture.whenComplete(() => _pendingMessages.remove(resultFuture));
|
||||
}
|
||||
@ -1780,8 +1780,7 @@ class _LiveTestRenderView extends RenderView {
|
||||
_label ??= TextPainter(textAlign: TextAlign.left, textDirection: TextDirection.ltr);
|
||||
_label!.text = TextSpan(text: value, style: _labelStyle);
|
||||
_label!.layout();
|
||||
if (onNeedPaint != null)
|
||||
onNeedPaint();
|
||||
onNeedPaint();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -1072,8 +1072,7 @@ class _TestTicker extends Ticker {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
if (_onDispose != null)
|
||||
_onDispose(this);
|
||||
_onDispose(this);
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user