getParagraph function

Paragraph getParagraph({
  1. String text = "",
  2. double fontsize = 0,
  3. Color textColor = const Color.fromARGB(0, 0, 0, 0),
  4. Size textSize = Size.zero,
})

生成一个字体的形状,来画出来

Implementation

ui.Paragraph getParagraph(
    {String text = "", double fontsize = 0, Color textColor = const Color.fromARGB(0, 0, 0, 0), Size textSize = Size.zero}) {
  //此处��须用ui���������中的,否则会找不到相关的路径
  ui.TextStyle ts = ui.TextStyle(color: textColor, fontSize: fontsize);

  //下面的代码是画text
  ui.ParagraphBuilder paragraphBuilder = ui.ParagraphBuilder(ui.ParagraphStyle(
    textDirection: TextDirection.ltr,
  ))
    ..pushStyle(ts)
    ..addText(text);
  ui.Paragraph paragraph = paragraphBuilder.build()
    ..layout(ui.ParagraphConstraints(width: textSize.width));
  return paragraph;
}