Skip to content

Canvas.drawParagraph should assert that Paragraph.layout has been called #97172

@dnfield

Description

@dnfield

For example, the following code should trigger an assert (it currently draws nothing and does not assert/error):

import 'dart:ui';

void main() {
  window.onBeginFrame = (_) {
    final a = createParagraph('asdf');
    final b = createParagraph('fdsa');

    final recorder = PictureRecorder();
    final canvas = Canvas(recorder);
    canvas.drawParagraph(a, const Offset(50, 100));
    canvas.drawParagraph(b, const Offset(50, 200));
    final picture = recorder.endRecording();

    final SceneBuilder builder = SceneBuilder();
    builder.addPicture(Offset.zero, picture);
    final scene = builder.build();
    window.render(scene);
    scene.dispose();
  };
  window.scheduleFrame();
}

Paragraph createParagraph(String text) {
  final builder = ParagraphBuilder(ParagraphStyle(fontSize: 36));
  builder.pushStyle(TextStyle(color: const Color(0xFFFEDCBA)));
  builder.addText(text);
  return builder.build(); //..layout(const ParagraphConstraints(width: double.infinity));
}

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: error messageError messages from the Flutter frameworkengineflutter/engine related. See also e: labels.

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions