File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -1328,7 +1328,7 @@ class DomParagraphBuilder implements ui.ParagraphBuilder {
13281328 /// paragraph. Plain text is more efficient to lay out and measure than rich
13291329 /// text.
13301330 EngineParagraph ? _tryBuildPlainText () {
1331- ui.Color color = _defaultTextColor ;
1331+ ui.Color ? color;
13321332 ui.TextDecoration ? decoration;
13331333 ui.Color ? decorationColor;
13341334 ui.TextDecorationStyle ? decorationStyle;
@@ -1416,6 +1416,10 @@ class DomParagraphBuilder implements ui.ParagraphBuilder {
14161416 i++ ;
14171417 }
14181418
1419+ if (color == null && foreground == null ) {
1420+ color = _defaultTextColor;
1421+ }
1422+
14191423 final EngineTextStyle cumulativeStyle = EngineTextStyle (
14201424 color: color,
14211425 decoration: decoration,
@@ -1443,7 +1447,7 @@ class DomParagraphBuilder implements ui.ParagraphBuilder {
14431447 paint = foreground;
14441448 } else {
14451449 paint = ui.Paint ();
1446- paint.color = color;
1450+ paint.color = color! ;
14471451 }
14481452
14491453 if (i >= _ops.length) {
Original file line number Diff line number Diff line change 22// Use of this source code is governed by a BSD-style license that can be
33// found in the LICENSE file.
44
5- // @dart = 2.6
5+ // @dart = 2.12
66import 'package:test/bootstrap/browser.dart' ;
77import 'package:test/test.dart' ;
88import 'package:ui/src/engine.dart' ;
@@ -28,10 +28,20 @@ void testMain() {
2828 expect (paragraph.height, isNonZero);
2929 });
3030
31- test ('PushStyle should not segfault after build()' , () {
31+ test ('pushStyle should not segfault after build()' , () {
3232 final ParagraphBuilder paragraphBuilder =
3333 ParagraphBuilder (ParagraphStyle ());
3434 paragraphBuilder.build ();
3535 paragraphBuilder.pushStyle (TextStyle ());
3636 });
37+
38+ test ('the presence of foreground style should not throw' , () {
39+ final ParagraphBuilder builder = ParagraphBuilder (ParagraphStyle ());
40+ builder.pushStyle (TextStyle (
41+ foreground: Paint ()..color = const Color (0xFFABCDEF ),
42+ ));
43+ builder.addText ('hi' );
44+
45+ expect (() => builder.build (), returnsNormally);
46+ });
3747}
You can’t perform that action at this time.
0 commit comments