Unverified Commit aac01897 authored by LongCatIsLooong's avatar LongCatIsLooong Committed by GitHub

Use pattern matching to avoid strange type annotations (#131964)

Addresses https://github.com/flutter/flutter/pull/131640#discussion_r1284861384
parent d7877d1f
......@@ -1918,15 +1918,13 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
bool hitTestChildren(BoxHitTestResult result, { required Offset position }) {
final Offset effectivePosition = position - _paintOffset;
final InlineSpan? textSpan = _textPainter.text;
if (textSpan != null) {
final TextPosition textPosition = _textPainter.getPositionForOffset(effectivePosition);
final Object? span = textSpan.getSpanForPosition(textPosition);
if (span is HitTestTarget) {
switch (textSpan?.getSpanForPosition(_textPainter.getPositionForOffset(effectivePosition))) {
case final HitTestTarget span:
result.add(HitTestEntry(span));
return true;
}
case _:
return hitTestInlineChildren(result, effectivePosition);
}
return hitTestInlineChildren(result, effectivePosition);
}
late TapGestureRecognizer _tap;
......
......@@ -725,12 +725,13 @@ class RenderParagraph extends RenderBox with ContainerRenderObjectMixin<RenderBo
@override
bool hitTestChildren(BoxHitTestResult result, { required Offset position }) {
final TextPosition textPosition = _textPainter.getPositionForOffset(position);
final Object? span = _textPainter.text!.getSpanForPosition(textPosition);
if (span is HitTestTarget) {
result.add(HitTestEntry(span));
return true;
switch (_textPainter.text!.getSpanForPosition(textPosition)) {
case final HitTestTarget span:
result.add(HitTestEntry(span));
return true;
case _:
return hitTestInlineChildren(result, position);
}
return hitTestInlineChildren(result, position);
}
bool _needsClipping = false;
......
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