Skip to content

Commit 88b77a7

Browse files
authored
Avoid use of ParagraphConstrains const ctor (flutter#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#26252, but broke internal embedders. We should re-enable use of the const constructor in those cases once internal embedders are updated. See: flutter#26390
1 parent 585e231 commit 88b77a7

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

examples/layers/raw/text.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ void main() {
8484
// Next, we supply a width that the text is permitted to occupy and we ask
8585
// the paragraph to the visual position of each its glyphs as well as its
8686
// overall size, subject to its sizing constraints.
87-
..layout(const ui.ParagraphConstraints(width: 180.0));
87+
// TODO(cbracken): use const constructor. https://github.com/flutter/flutter/issues/26390
88+
// ignore:prefer_const_constructors
89+
..layout(ui.ParagraphConstraints(width: 180.0));
8890

8991
// Finally, we register our beginFrame callback and kick off the first frame.
9092
ui.window.onBeginFrame = beginFrame;

packages/flutter/lib/src/painting/text_painter.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,9 @@ class TextPainter {
242242
builder.pushStyle(text.style.getTextStyle(textScaleFactor: textScaleFactor));
243243
builder.addText(' ');
244244
_layoutTemplate = builder.build()
245-
..layout(const ui.ParagraphConstraints(width: double.infinity));
245+
// TODO(cbracken): use const constructor. https://github.com/flutter/flutter/issues/26390
246+
// ignore:prefer_const_constructors
247+
..layout(ui.ParagraphConstraints(width: double.infinity));
246248
}
247249
return _layoutTemplate.height;
248250
}

packages/flutter/test/engine/paragraph_builder_test.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ void main() {
1313
final Paragraph paragraph = builder.build();
1414
expect(paragraph, isNotNull);
1515

16-
paragraph.layout(const ParagraphConstraints(width: 800.0));
16+
// TODO(cbracken): use const constructor. https://github.com/flutter/flutter/issues/26390
17+
// ignore:prefer_const_constructors
18+
paragraph.layout(ParagraphConstraints(width: 800.0));
1719
expect(paragraph.width, isNonZero);
1820
expect(paragraph.height, isNonZero);
1921
});

packages/flutter/test/engine/paragraph_test.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ void main() {
2020
));
2121
builder.addText('Test');
2222
final Paragraph paragraph = builder.build();
23-
paragraph.layout(const ParagraphConstraints(width: 400.0));
23+
// TODO(cbracken): use const constructor. https://github.com/flutter/flutter/issues/26390
24+
// ignore:prefer_const_constructors
25+
paragraph.layout(ParagraphConstraints(width: 400.0));
2426

2527
expect(paragraph.height, closeTo(fontSize, 0.001));
2628
expect(paragraph.width, closeTo(400.0, 0.001));

0 commit comments

Comments
 (0)