getParagraph function

Paragraph getParagraph({
  1. String? text,
  2. double? fontsize,
  3. Color? textColor,
  4. Size? textSize,
})

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

Implementation

ui.Paragraph getParagraph(
    {String? text, double? fontsize, Color? textColor, Size? textSize}) {
  //此处��须用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;
}