Skip to content

DomParagraph _tryBuildPlainText should not default color #72076

@dnfield

Description

@dnfield

For example, this program will fail on web:

import 'dart:ui';

void main() {
  final ParagraphBuilder builder = ParagraphBuilder(ParagraphStyle());
  builder.pushStyle(TextStyle(foreground: Paint()..color = const Color(0xFFABCDEF)));
  builder.addText('hi');
  final Paragraph paragraph = builder.build(); // assertion error
  print(paragraph);
}
dart_sdk.js:4205 Uncaught (in promise) Error: Assertion failed: org-dartlang-sdk:///flutter_web_sdk/lib/_engine/engine/text/paragraph.dart:949:13
color == null || foreground == null
"Cannot provide both a color and a foreground\nThe color argument is just a shorthand for \"foreground: new Paint()..color = color\"."
    at Object.throw_ [as throw] (dart_sdk.js:4205)
    at Object.assertFailed (dart_sdk.js:4151)
    at new _engine.EngineTextStyle.only (dart_sdk.js:160215)
    at _engine.DomParagraphBuilder.new.[_tryBuildPlainText] (dart_sdk.js:160439)
    at _engine.DomParagraphBuilder.new.build (dart_sdk.js:160353)
    at Object.main$0 [as main] (<anonymous>:70:29)
    at main$ (<anonymous>:57:12)
    at main$.next (<anonymous>)
    at dart_sdk.js:36192
    at _RootZone.runUnary (dart_sdk.js:36060)
    at _FutureListener.thenAwait.handleValue (dart_sdk.js:31289)
    at handleValueCallback (dart_sdk.js:31804)
    at Function._propagateToListeners (dart_sdk.js:31842)
    at async._AsyncCallbackEntry.new.callback (dart_sdk.js:31579)
    at Object._microtaskLoop (dart_sdk.js:36297)
    at _startMicrotaskLoop (dart_sdk.js:36303)
    at dart_sdk.js:32051

The problem is at https://github.com/flutter/engine/blob/91ec9451dd3fb1d5424dc4551653774541640931/lib/web_ui/lib/src/engine/text/paragraph.dart#L1331 - I'm not quite clear on the implications of changing that though. At any rate, if the foreground property is specified we can't specify the color.

/cc @hterkelsen @yjbanov @mdebbar
/cc @GROOVIZ - this is the cause of dnfield/flutter_svg#463

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: typographyText rendering, possibly libtxtassigned for triageissue is assigned to a domain expert for further triagee: web_htmlHTML rendering backend for Webengineflutter/engine related. See also e: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions