drawText method

void drawText(
  1. String text,
  2. double x,
  3. double y,
  4. UiPaint paint,
  5. UiTextPaint textPaint,
  6. double maxTextWidth,
)

draws the given text so that the center of the text in at the given x/y coordinates

Implementation

void drawText(String text, double x, double y, UiPaint paint, UiTextPaint textPaint, double maxTextWidth) {
  ParagraphEntry entry = ParagraphCacheMgr().getEntry(text, textPaint, paint, maxTextWidth);
  double textwidth = entry.getWidth();
  double textHeight = entry.getHeight();
  if (x + textwidth / 2 < 0 || y + entry.getHeight() < 0 || x - textwidth / 2 > _size.width || y - entry.getHeight() > _size.height) return;
  // uiCanvas.drawRect(
  //     ui.Rect.fromLTWH(x - textwidth / 2, y - textHeight / 2,
  //         entry.getWidth(), entry.getHeight()),
  //     ui.Paint()..color = Colors.red.withOpacity(0.7));
  // uiCanvas.drawCircle(ui.Offset(x - textwidth / 2, y - textHeight / 2), 10,
  //     ui.Paint()..color = Colors.green);
  _uiCanvas.drawParagraph(entry.paragraph, ui.Offset(x - textwidth / 2, y - textHeight / 2));
  // uiCanvas.drawCircle(ui.Offset(x, y), 5, ui.Paint()..color = Colors.blue);
  ++_textCount;
}