Unverified Commit 74ac7c47 authored by chunhtai's avatar chunhtai Committed by GitHub

Fix empty textspan with spell out crashes (#88738)

parent 577832fb
......@@ -371,13 +371,14 @@ class TextSpan extends InlineSpan implements HitTestTarget, MouseTrackerAnnotati
final bool effectiveSpellOut = spellOut ?? inheritedSpellOut;
if (text != null) {
final int textLength = semanticsLabel?.length ?? text!.length;
collector.add(InlineSpanSemanticsInformation(
text!,
stringAttributes: <ui.StringAttribute>[
if (effectiveSpellOut)
ui.SpellOutStringAttribute(range: TextRange(start: 0, end: semanticsLabel?.length ?? text!.length)),
if (effectiveLocale != null)
ui.LocaleStringAttribute(locale: effectiveLocale, range: TextRange(start: 0, end: semanticsLabel?.length ?? text!.length)),
if (effectiveSpellOut && textLength > 0)
ui.SpellOutStringAttribute(range: TextRange(start: 0, end: textLength)),
if (effectiveLocale != null && textLength > 0)
ui.LocaleStringAttribute(locale: effectiveLocale, range: TextRange(start: 0, end: textLength)),
],
semanticsLabel: semanticsLabel,
recognizer: recognizer,
......
......@@ -749,6 +749,18 @@ void main() {
paragraph.assembleSemanticsNode(SemanticsNode(), SemanticsConfiguration(), <SemanticsNode>[]);
});
test('Supports empty text span with spell out', () {
final RenderParagraph paragraph = RenderParagraph(
const TextSpan(text: '', spellOut: true),
textDirection: TextDirection.rtl,
);
layout(paragraph);
final SemanticsNode node = SemanticsNode();
paragraph.assembleSemanticsNode(node, SemanticsConfiguration(), <SemanticsNode>[]);
expect(node.attributedLabel.string, '');
expect(node.attributedLabel.attributes.length, 0);
});
test('Asserts on unsupported gesture recognizer', () {
final RenderParagraph paragraph = RenderParagraph(
TextSpan(text: _kText, children: <InlineSpan>[
......
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