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 }) {
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user