Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draw textspan #10

Open
softmarshmallow opened this issue Sep 28, 2020 · 2 comments
Open

draw textspan #10

softmarshmallow opened this issue Sep 28, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@softmarshmallow
Copy link

  drawText(TouchyCanvas canvas) {
    TextSpan span = new TextSpan(
        style: new TextStyle(color: Colors.blue[800]), text: "name");
    TextPainter tp = new TextPainter(
        text: span,
        textAlign: TextAlign.left,
        textDirection: TextDirection.ltr);
    tp.layout();
    tp.paint(canvas as Canvas, new Offset(5.0, 5.0));
  }

Expected a value of type 'Canvas', but got one of type 'TouchyCanvas'

@issue-label-bot issue-label-bot bot added the bug Something isn't working label Sep 28, 2020
@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.60. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@kataro92
Copy link

You can use Canvas from origin just like below code:

@override
void paint(Canvas originCanvas) {
    var canvas = TouchyCanvas(context, originCanvas);
}

drawText(TouchyCanvas canvas) {
    TextSpan span = new TextSpan(
        style: new TextStyle(color: Colors.blue[800]), text: "name");
    TextPainter tp = new TextPainter(
        text: span,
        textAlign: TextAlign.left,
        textDirection: TextDirection.ltr);
    tp.layout();
    tp.paint(originCanvas, new Offset(5.0, 5.0));
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants