Avoid use of ParagraphConstrains const ctor (#26392)
Usages of ParagraphConstraints (from dart:ui) whose constructor could be const as of flutter/engine#7346 are currently marked // ignore:prefer_const_constructors in the framework until all Google-internal embedders have been updated to an engine version that includes the above change. These were initially updated in engine roll flutter/flutter#26252, but broke internal embedders. We should re-enable use of the const constructor in those cases once internal embedders are updated. See: https://github.com/flutter/flutter/issues/26390
This commit is contained in:
parent
585e23173a
commit
88b77a7d0f
@ -84,7 +84,9 @@ void main() {
|
|||||||
// Next, we supply a width that the text is permitted to occupy and we ask
|
// Next, we supply a width that the text is permitted to occupy and we ask
|
||||||
// the paragraph to the visual position of each its glyphs as well as its
|
// the paragraph to the visual position of each its glyphs as well as its
|
||||||
// overall size, subject to its sizing constraints.
|
// overall size, subject to its sizing constraints.
|
||||||
..layout(const ui.ParagraphConstraints(width: 180.0));
|
// TODO(cbracken): use const constructor. https://github.com/flutter/flutter/issues/26390
|
||||||
|
// ignore:prefer_const_constructors
|
||||||
|
..layout(ui.ParagraphConstraints(width: 180.0));
|
||||||
|
|
||||||
// Finally, we register our beginFrame callback and kick off the first frame.
|
// Finally, we register our beginFrame callback and kick off the first frame.
|
||||||
ui.window.onBeginFrame = beginFrame;
|
ui.window.onBeginFrame = beginFrame;
|
||||||
|
@ -242,7 +242,9 @@ class TextPainter {
|
|||||||
builder.pushStyle(text.style.getTextStyle(textScaleFactor: textScaleFactor));
|
builder.pushStyle(text.style.getTextStyle(textScaleFactor: textScaleFactor));
|
||||||
builder.addText(' ');
|
builder.addText(' ');
|
||||||
_layoutTemplate = builder.build()
|
_layoutTemplate = builder.build()
|
||||||
..layout(const ui.ParagraphConstraints(width: double.infinity));
|
// TODO(cbracken): use const constructor. https://github.com/flutter/flutter/issues/26390
|
||||||
|
// ignore:prefer_const_constructors
|
||||||
|
..layout(ui.ParagraphConstraints(width: double.infinity));
|
||||||
}
|
}
|
||||||
return _layoutTemplate.height;
|
return _layoutTemplate.height;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,9 @@ void main() {
|
|||||||
final Paragraph paragraph = builder.build();
|
final Paragraph paragraph = builder.build();
|
||||||
expect(paragraph, isNotNull);
|
expect(paragraph, isNotNull);
|
||||||
|
|
||||||
paragraph.layout(const ParagraphConstraints(width: 800.0));
|
// TODO(cbracken): use const constructor. https://github.com/flutter/flutter/issues/26390
|
||||||
|
// ignore:prefer_const_constructors
|
||||||
|
paragraph.layout(ParagraphConstraints(width: 800.0));
|
||||||
expect(paragraph.width, isNonZero);
|
expect(paragraph.width, isNonZero);
|
||||||
expect(paragraph.height, isNonZero);
|
expect(paragraph.height, isNonZero);
|
||||||
});
|
});
|
||||||
|
@ -20,7 +20,9 @@ void main() {
|
|||||||
));
|
));
|
||||||
builder.addText('Test');
|
builder.addText('Test');
|
||||||
final Paragraph paragraph = builder.build();
|
final Paragraph paragraph = builder.build();
|
||||||
paragraph.layout(const ParagraphConstraints(width: 400.0));
|
// TODO(cbracken): use const constructor. https://github.com/flutter/flutter/issues/26390
|
||||||
|
// ignore:prefer_const_constructors
|
||||||
|
paragraph.layout(ParagraphConstraints(width: 400.0));
|
||||||
|
|
||||||
expect(paragraph.height, closeTo(fontSize, 0.001));
|
expect(paragraph.height, closeTo(fontSize, 0.001));
|
||||||
expect(paragraph.width, closeTo(400.0, 0.001));
|
expect(paragraph.width, closeTo(400.0, 0.001));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user