[web] Fix layout exception when text is null (flutter/engine#23653)

This commit is contained in:
Mouad Debbar 2021-01-13 11:54:02 -08:00 committed by GitHub
parent 8af69442c0
commit a21b2be8bb
2 changed files with 14 additions and 0 deletions

View File

@ -71,6 +71,10 @@ class TextLayoutService {
didExceedMaxLines = false;
lines.clear();
if (spanCount == 0) {
return;
}
final Spanometer spanometer = Spanometer(paragraph, context);
int spanIndex = 0;

View File

@ -42,6 +42,16 @@ void main() {
void testMain() async {
await ui.webOnlyInitializeTestDomRenderer();
test('no text', () {
final CanvasParagraph paragraph = CanvasParagraphBuilder(ahemStyle).build();
paragraph.layout(constrain(double.infinity));
expect(paragraph.maxIntrinsicWidth, 0);
expect(paragraph.minIntrinsicWidth, 0);
expect(paragraph.height, 0);
expect(paragraph.computeLineMetrics(), isEmpty);
});
test('preserves whitespace when measuring', () {
CanvasParagraph paragraph;