generateParagraph static method

dynamic generateParagraph(
  1. DanmakuContentItem content,
  2. double danmakuWidth,
  3. double fontSize,
  4. int fontWeight,
)

Implementation

static generateParagraph(DanmakuContentItem content, double danmakuWidth,
    double fontSize, int fontWeight) {
  final ui.ParagraphBuilder builder = ui.ParagraphBuilder(ui.ParagraphStyle(
    textAlign: TextAlign.left,
    fontSize: fontSize,
    fontWeight: FontWeight.values[fontWeight],
    textDirection: TextDirection.ltr,
  ))
    ..pushStyle(ui.TextStyle(
      color: content.color,
    ))
    ..addText(content.text);
  return builder.build()
    ..layout(ui.ParagraphConstraints(width: danmakuWidth));
}