Unverified Commit 304e2c57 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

fix nullability issues (#67306)

parent c14ab91f
...@@ -495,7 +495,7 @@ class TrainHoppingAnimation extends Animation<double> ...@@ -495,7 +495,7 @@ class TrainHoppingAnimation extends Animation<double>
: assert(_currentTrain != null) { : assert(_currentTrain != null) {
if (_nextTrain != null) { if (_nextTrain != null) {
if (_currentTrain!.value == _nextTrain!.value) { if (_currentTrain!.value == _nextTrain!.value) {
_currentTrain = _nextTrain!; _currentTrain = _nextTrain;
_nextTrain = null; _nextTrain = null;
} else if (_currentTrain!.value > _nextTrain!.value) { } else if (_currentTrain!.value > _nextTrain!.value) {
_mode = _TrainHoppingMode.maximize; _mode = _TrainHoppingMode.maximize;
...@@ -557,7 +557,7 @@ class TrainHoppingAnimation extends Animation<double> ...@@ -557,7 +557,7 @@ class TrainHoppingAnimation extends Animation<double>
_currentTrain! _currentTrain!
..removeStatusListener(_statusChangeHandler) ..removeStatusListener(_statusChangeHandler)
..removeListener(_valueChangeHandler); ..removeListener(_valueChangeHandler);
_currentTrain = _nextTrain!; _currentTrain = _nextTrain;
_nextTrain = null; _nextTrain = null;
_currentTrain!.addStatusListener(_statusChangeHandler); _currentTrain!.addStatusListener(_statusChangeHandler);
_statusChangeHandler(_currentTrain!.status); _statusChangeHandler(_currentTrain!.status);
......
...@@ -186,7 +186,7 @@ class CupertinoPicker extends StatefulWidget { ...@@ -186,7 +186,7 @@ class CupertinoPicker extends StatefulWidget {
/// This can be called during scrolls and during ballistic flings. To get the /// This can be called during scrolls and during ballistic flings. To get the
/// value only when the scrolling settles, use a [NotificationListener], /// value only when the scrolling settles, use a [NotificationListener],
/// listen for [ScrollEndNotification] and read its [FixedExtentMetrics]. /// listen for [ScrollEndNotification] and read its [FixedExtentMetrics].
final ValueChanged<int> onSelectedItemChanged; final ValueChanged<int>? onSelectedItemChanged;
/// A delegate that lazily instantiates children. /// A delegate that lazily instantiates children.
final ListWheelChildDelegate childDelegate; final ListWheelChildDelegate childDelegate;
...@@ -247,7 +247,7 @@ class _CupertinoPickerState extends State<CupertinoPicker> { ...@@ -247,7 +247,7 @@ class _CupertinoPickerState extends State<CupertinoPicker> {
} }
if (widget.onSelectedItemChanged != null) { if (widget.onSelectedItemChanged != null) {
widget.onSelectedItemChanged(index); widget.onSelectedItemChanged!(index);
} }
} }
......
...@@ -172,7 +172,7 @@ class _CupertinoTabViewState extends State<CupertinoTabView> { ...@@ -172,7 +172,7 @@ class _CupertinoTabViewState extends State<CupertinoTabView> {
WidgetBuilder? routeBuilder; WidgetBuilder? routeBuilder;
String? title; String? title;
if (name == Navigator.defaultRouteName && widget.builder != null) { if (name == Navigator.defaultRouteName && widget.builder != null) {
routeBuilder = widget.builder!; routeBuilder = widget.builder;
title = widget.defaultTitle; title = widget.defaultTitle;
} else if (widget.routes != null) { } else if (widget.routes != null) {
routeBuilder = widget.routes![name]; routeBuilder = widget.routes![name];
......
...@@ -46,7 +46,7 @@ class TextParentData extends ContainerBoxParentData<RenderBox> { ...@@ -46,7 +46,7 @@ class TextParentData extends ContainerBoxParentData<RenderBox> {
@override @override
String toString() { String toString() {
final List<String> values = <String>[ final List<String> values = <String>[
if (offset != null) 'offset=$offset', 'offset=$offset',
if (scale != null) 'scale=$scale', if (scale != null) 'scale=$scale',
super.toString(), super.toString(),
]; ];
...@@ -819,14 +819,12 @@ class RenderParagraph extends RenderBox ...@@ -819,14 +819,12 @@ class RenderParagraph extends RenderBox
String? workingLabel; String? workingLabel;
for (final InlineSpanSemanticsInformation info in _semanticsInfo!) { for (final InlineSpanSemanticsInformation info in _semanticsInfo!) {
if (info.requiresOwnNode) { if (info.requiresOwnNode) {
if (workingText != null) {
combined.add(InlineSpanSemanticsInformation( combined.add(InlineSpanSemanticsInformation(
workingText, workingText,
semanticsLabel: workingLabel ?? workingText, semanticsLabel: workingLabel ?? workingText,
)); ));
workingText = ''; workingText = '';
workingLabel = null; workingLabel = null;
}
combined.add(info); combined.add(info);
} else { } else {
workingText += info.text; workingText += info.text;
...@@ -838,14 +836,10 @@ class RenderParagraph extends RenderBox ...@@ -838,14 +836,10 @@ class RenderParagraph extends RenderBox
} }
} }
} }
if (workingText != null) {
combined.add(InlineSpanSemanticsInformation( combined.add(InlineSpanSemanticsInformation(
workingText, workingText,
semanticsLabel: workingLabel, semanticsLabel: workingLabel,
)); ));
} else { // ignore: dead_code
assert(workingLabel != null);
}
return combined; return combined;
} }
......
...@@ -4481,7 +4481,6 @@ class RenderSemanticsAnnotations extends RenderProxyBox { ...@@ -4481,7 +4481,6 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
void describeSemanticsConfiguration(SemanticsConfiguration config) { void describeSemanticsConfiguration(SemanticsConfiguration config) {
super.describeSemanticsConfiguration(config); super.describeSemanticsConfiguration(config);
config.isSemanticBoundary = container; config.isSemanticBoundary = container;
if (explicitChildNodes != null)
config.explicitChildNodes = explicitChildNodes; config.explicitChildNodes = explicitChildNodes;
assert((scopesRoute == true && explicitChildNodes == true) || scopesRoute != true, assert((scopesRoute == true && explicitChildNodes == true) || scopesRoute != true,
'explicitChildNodes must be set to true if scopes route is true'); 'explicitChildNodes must be set to true if scopes route is true');
......
...@@ -1085,7 +1085,6 @@ class RenderTable extends RenderBox { ...@@ -1085,7 +1085,6 @@ class RenderTable extends RenderBox {
final TableCellParentData childParentData = child.parentData! as TableCellParentData; final TableCellParentData childParentData = child.parentData! as TableCellParentData;
switch (childParentData.verticalAlignment ?? defaultVerticalAlignment) { switch (childParentData.verticalAlignment ?? defaultVerticalAlignment) {
case TableCellVerticalAlignment.baseline: case TableCellVerticalAlignment.baseline:
if (baselines[x] != null)
childParentData.offset = Offset(positions[x], rowTop + beforeBaselineDistance - baselines[x]); childParentData.offset = Offset(positions[x], rowTop + beforeBaselineDistance - baselines[x]);
break; break;
case TableCellVerticalAlignment.top: case TableCellVerticalAlignment.top:
......
...@@ -510,15 +510,7 @@ class _SemanticsDiagnosticableNode extends DiagnosticableNode<SemanticsNode> { ...@@ -510,15 +510,7 @@ class _SemanticsDiagnosticableNode extends DiagnosticableNode<SemanticsNode> {
final DebugSemanticsDumpOrder childOrder; final DebugSemanticsDumpOrder childOrder;
@override @override
List<DiagnosticsNode> getChildren() { List<DiagnosticsNode> getChildren() => value.debugDescribeChildren(childOrder: childOrder);
if (value != null)
return value.debugDescribeChildren(childOrder: childOrder);
// `value` has a non-nullable return type, but might be null when
// running with weak checking, so we need to null check it above (and
// ignore the warning below that the null-handling logic is dead code).
return const <DiagnosticsNode>[]; // ignore: dead_code
}
} }
/// Provides hint values which override the default hints on supported /// Provides hint values which override the default hints on supported
...@@ -1419,12 +1411,10 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { ...@@ -1419,12 +1411,10 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
for (final SemanticsNode child in _children!) for (final SemanticsNode child in _children!)
child._dead = true; child._dead = true;
} }
if (newChildren != null) {
for (final SemanticsNode child in newChildren) { for (final SemanticsNode child in newChildren) {
assert(!child.isInvisible, 'Child $child is invisible and should not be added as a child of $this.'); assert(!child.isInvisible, 'Child $child is invisible and should not be added as a child of $this.');
child._dead = false; child._dead = false;
} }
}
bool sawChange = false; bool sawChange = false;
if (_children != null) { if (_children != null) {
for (final SemanticsNode child in _children!) { for (final SemanticsNode child in _children!) {
...@@ -1438,7 +1428,6 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { ...@@ -1438,7 +1428,6 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
} }
} }
} }
if (newChildren != null) {
for (final SemanticsNode child in newChildren) { for (final SemanticsNode child in newChildren) {
if (child.parent != this) { if (child.parent != this) {
if (child.parent != null) { if (child.parent != null) {
...@@ -1454,7 +1443,6 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { ...@@ -1454,7 +1443,6 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
sawChange = true; sawChange = true;
} }
} }
}
if (!sawChange && _children != null) { if (!sawChange && _children != null) {
assert(newChildren != null); assert(newChildren != null);
assert(newChildren.length == _children!.length); assert(newChildren.length == _children!.length);
...@@ -1966,10 +1954,8 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { ...@@ -1966,10 +1954,8 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
mergedTags ??= <SemanticsTag>{}; mergedTags ??= <SemanticsTag>{};
mergedTags!.addAll(node.tags!); mergedTags!.addAll(node.tags!);
} }
if (node._customSemanticsActions != null) {
for (final CustomSemanticsAction action in _customSemanticsActions.keys) for (final CustomSemanticsAction action in _customSemanticsActions.keys)
customSemanticsActionIds.add(CustomSemanticsAction.getIdentifier(action)); customSemanticsActionIds.add(CustomSemanticsAction.getIdentifier(action));
}
if (node.hintOverrides != null) { if (node.hintOverrides != null) {
if (node.hintOverrides!.onTapHint != null) { if (node.hintOverrides!.onTapHint != null) {
final CustomSemanticsAction action = CustomSemanticsAction.overridingAction( final CustomSemanticsAction action = CustomSemanticsAction.overridingAction(
......
...@@ -790,7 +790,7 @@ abstract class TextInputClient { ...@@ -790,7 +790,7 @@ abstract class TextInputClient {
const TextInputClient(); const TextInputClient();
/// The current state of the [TextEditingValue] held by this client. /// The current state of the [TextEditingValue] held by this client.
TextEditingValue get currentTextEditingValue; TextEditingValue? get currentTextEditingValue;
/// The [AutofillScope] this [TextInputClient] belongs to, if any. /// The [AutofillScope] this [TextInputClient] belongs to, if any.
/// ///
...@@ -1164,7 +1164,7 @@ class TextInput { ...@@ -1164,7 +1164,7 @@ class TextInput {
if (method == 'TextInputClient.requestExistingInputState') { if (method == 'TextInputClient.requestExistingInputState') {
assert(_currentConnection!._client != null); assert(_currentConnection!._client != null);
_attach(_currentConnection!, _currentConfiguration); _attach(_currentConnection!, _currentConfiguration);
final TextEditingValue editingValue = _currentConnection!._client.currentTextEditingValue; final TextEditingValue? editingValue = _currentConnection!._client.currentTextEditingValue;
if (editingValue != null) { if (editingValue != null) {
_setEditingState(editingValue); _setEditingState(editingValue);
} }
......
...@@ -105,12 +105,7 @@ class DecoratedBox extends SingleChildRenderObjectWidget { ...@@ -105,12 +105,7 @@ class DecoratedBox extends SingleChildRenderObjectWidget {
break; break;
} }
properties.add(EnumProperty<DecorationPosition>('position', position, level: DiagnosticLevel.hidden)); properties.add(EnumProperty<DecorationPosition>('position', position, level: DiagnosticLevel.hidden));
properties.add(DiagnosticsProperty<Decoration>( properties.add(DiagnosticsProperty<Decoration>(label, decoration));
label,
decoration,
ifNull: 'no decoration',
showName: decoration != null,
));
} }
} }
......
...@@ -527,9 +527,7 @@ class _FocusState extends State<Focus> { ...@@ -527,9 +527,7 @@ class _FocusState extends State<Focus> {
// _createNode is overridden in _FocusScopeState. // _createNode is overridden in _FocusScopeState.
_internalNode ??= _createNode(); _internalNode ??= _createNode();
} }
if (widget.descendantsAreFocusable != null) {
focusNode.descendantsAreFocusable = widget.descendantsAreFocusable; focusNode.descendantsAreFocusable = widget.descendantsAreFocusable;
}
if (widget.skipTraversal != null) { if (widget.skipTraversal != null) {
focusNode.skipTraversal = widget.skipTraversal!; focusNode.skipTraversal = widget.skipTraversal!;
} }
...@@ -615,9 +613,7 @@ class _FocusState extends State<Focus> { ...@@ -615,9 +613,7 @@ class _FocusState extends State<Focus> {
if (widget.canRequestFocus != null) { if (widget.canRequestFocus != null) {
focusNode.canRequestFocus = widget.canRequestFocus!; focusNode.canRequestFocus = widget.canRequestFocus!;
} }
if (widget.descendantsAreFocusable != null) {
focusNode.descendantsAreFocusable = widget.descendantsAreFocusable; focusNode.descendantsAreFocusable = widget.descendantsAreFocusable;
}
} else { } else {
_focusAttachment!.detach(); _focusAttachment!.detach();
focusNode.removeListener(_handleFocusChanged); focusNode.removeListener(_handleFocusChanged);
......
...@@ -116,8 +116,7 @@ class _LayoutBuilderElement<ConstraintType extends Constraints> extends RenderOb ...@@ -116,8 +116,7 @@ class _LayoutBuilderElement<ConstraintType extends Constraints> extends RenderOb
void _layout(ConstraintType constraints) { void _layout(ConstraintType constraints) {
owner!.buildScope(this, () { owner!.buildScope(this, () {
Widget? built; Widget built;
if (widget.builder != null) {
try { try {
built = widget.builder(this, constraints); built = widget.builder(this, constraints);
debugWidgetBuilderValue(widget, built); debugWidgetBuilderValue(widget, built);
...@@ -133,7 +132,6 @@ class _LayoutBuilderElement<ConstraintType extends Constraints> extends RenderOb ...@@ -133,7 +132,6 @@ class _LayoutBuilderElement<ConstraintType extends Constraints> extends RenderOb
), ),
); );
} }
}
try { try {
_child = updateChild(_child, built, null); _child = updateChild(_child, built, null);
assert(_child != null); assert(_child != null);
......
...@@ -3603,11 +3603,11 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res ...@@ -3603,11 +3603,11 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
assert(previousOldPageRouteEntry != null); assert(previousOldPageRouteEntry != null);
final List<_RouteEntry> pagelessRoutes = pageRouteToPagelessRoutes final List<_RouteEntry> pagelessRoutes = pageRouteToPagelessRoutes
.putIfAbsent( .putIfAbsent(
previousOldPageRouteEntry!, previousOldPageRouteEntry,
() => <_RouteEntry>[], () => <_RouteEntry>[],
); );
pagelessRoutes.add(potentialEntryToRemove); pagelessRoutes.add(potentialEntryToRemove);
if (previousOldPageRouteEntry.isWaitingForExitingDecision) if (previousOldPageRouteEntry!.isWaitingForExitingDecision)
potentialEntryToRemove.markNeedsExitingDecision(); potentialEntryToRemove.markNeedsExitingDecision();
continue; continue;
} }
...@@ -3651,7 +3651,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res ...@@ -3651,7 +3651,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
assert(previousOldPageRouteEntry != null); assert(previousOldPageRouteEntry != null);
final List<_RouteEntry> pagelessRoutes = pageRouteToPagelessRoutes final List<_RouteEntry> pagelessRoutes = pageRouteToPagelessRoutes
.putIfAbsent( .putIfAbsent(
previousOldPageRouteEntry!, previousOldPageRouteEntry,
() => <_RouteEntry>[] () => <_RouteEntry>[]
); );
pagelessRoutes.add(oldEntry); pagelessRoutes.add(oldEntry);
......
...@@ -808,10 +808,7 @@ class _NestedScrollCoordinator implements ScrollActivityDelegate, ScrollHoldCont ...@@ -808,10 +808,7 @@ class _NestedScrollCoordinator implements ScrollActivityDelegate, ScrollHoldCont
return false; return false;
} }
void updateShadow() { void updateShadow() { _onHasScrolledBodyChanged(); }
if (_onHasScrolledBodyChanged != null)
_onHasScrolledBodyChanged();
}
ScrollDirection get userScrollDirection => _userScrollDirection; ScrollDirection get userScrollDirection => _userScrollDirection;
ScrollDirection _userScrollDirection = ScrollDirection.idle; ScrollDirection _userScrollDirection = ScrollDirection.idle;
......
...@@ -1107,7 +1107,7 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render ...@@ -1107,7 +1107,7 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
if (childParentData != null) if (childParentData != null)
childParentData.layoutOffset = null; childParentData.layoutOffset = null;
newChildren[newIndex] = _childElements[index]!; newChildren[newIndex] = _childElements[index];
// We need to make sure the original index gets processed. // We need to make sure the original index gets processed.
newChildren.putIfAbsent(index, () => null); newChildren.putIfAbsent(index, () => null);
// We do not want the remapped child to get deactivated during processElement. // We do not want the remapped child to get deactivated during processElement.
......
...@@ -970,7 +970,7 @@ mixin WidgetInspectorService { ...@@ -970,7 +970,7 @@ mixin WidgetInspectorService {
void initServiceExtensions(_RegisterServiceExtensionCallback registerServiceExtensionCallback) { void initServiceExtensions(_RegisterServiceExtensionCallback registerServiceExtensionCallback) {
_structuredExceptionHandler = _reportError; _structuredExceptionHandler = _reportError;
if (isStructuredErrorsEnabled()) { if (isStructuredErrorsEnabled()) {
FlutterError.onError = _structuredExceptionHandler!; FlutterError.onError = _structuredExceptionHandler;
} }
_registerServiceExtensionCallback = registerServiceExtensionCallback; _registerServiceExtensionCallback = registerServiceExtensionCallback;
assert(!_debugServiceExtensionsRegistered); assert(!_debugServiceExtensionsRegistered);
...@@ -2284,11 +2284,9 @@ class _WidgetInspectorState extends State<WidgetInspector> ...@@ -2284,11 +2284,9 @@ class _WidgetInspectorState extends State<WidgetInspector>
if (_lastPointerLocation != null) { if (_lastPointerLocation != null) {
_inspectAt(_lastPointerLocation!); _inspectAt(_lastPointerLocation!);
if (selection != null) {
// Notify debuggers to open an inspector on the object. // Notify debuggers to open an inspector on the object.
developer.inspect(selection.current); developer.inspect(selection.current);
} }
}
setState(() { setState(() {
// Only exit select mode if there is a button to return to select mode. // Only exit select mode if there is a button to return to select mode.
if (widget.selectButtonBuilder != null) if (widget.selectButtonBuilder != null)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment