Use pattern matching to avoid strange type annotations (#131964)
Addresses https://github.com/flutter/flutter/pull/131640#discussion_r1284861384
This commit is contained in:
parent
d7877d1fe0
commit
aac018974f
@ -1918,15 +1918,13 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
|
|||||||
bool hitTestChildren(BoxHitTestResult result, { required Offset position }) {
|
bool hitTestChildren(BoxHitTestResult result, { required Offset position }) {
|
||||||
final Offset effectivePosition = position - _paintOffset;
|
final Offset effectivePosition = position - _paintOffset;
|
||||||
final InlineSpan? textSpan = _textPainter.text;
|
final InlineSpan? textSpan = _textPainter.text;
|
||||||
if (textSpan != null) {
|
switch (textSpan?.getSpanForPosition(_textPainter.getPositionForOffset(effectivePosition))) {
|
||||||
final TextPosition textPosition = _textPainter.getPositionForOffset(effectivePosition);
|
case final HitTestTarget span:
|
||||||
final Object? span = textSpan.getSpanForPosition(textPosition);
|
|
||||||
if (span is HitTestTarget) {
|
|
||||||
result.add(HitTestEntry(span));
|
result.add(HitTestEntry(span));
|
||||||
return true;
|
return true;
|
||||||
}
|
case _:
|
||||||
|
return hitTestInlineChildren(result, effectivePosition);
|
||||||
}
|
}
|
||||||
return hitTestInlineChildren(result, effectivePosition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
late TapGestureRecognizer _tap;
|
late TapGestureRecognizer _tap;
|
||||||
|
@ -725,12 +725,13 @@ class RenderParagraph extends RenderBox with ContainerRenderObjectMixin<RenderBo
|
|||||||
@override
|
@override
|
||||||
bool hitTestChildren(BoxHitTestResult result, { required Offset position }) {
|
bool hitTestChildren(BoxHitTestResult result, { required Offset position }) {
|
||||||
final TextPosition textPosition = _textPainter.getPositionForOffset(position);
|
final TextPosition textPosition = _textPainter.getPositionForOffset(position);
|
||||||
final Object? span = _textPainter.text!.getSpanForPosition(textPosition);
|
switch (_textPainter.text!.getSpanForPosition(textPosition)) {
|
||||||
if (span is HitTestTarget) {
|
case final HitTestTarget span:
|
||||||
result.add(HitTestEntry(span));
|
result.add(HitTestEntry(span));
|
||||||
return true;
|
return true;
|
||||||
|
case _:
|
||||||
|
return hitTestInlineChildren(result, position);
|
||||||
}
|
}
|
||||||
return hitTestInlineChildren(result, position);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _needsClipping = false;
|
bool _needsClipping = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user