generateStrokeParagraph static method

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

Implementation

static generateStrokeParagraph(DanmakuContentItem content,
    double danmakuWidth, double fontSize, int fontWeight) {
  final Paint strokePaint = Paint()
    ..style = PaintingStyle.stroke
    ..strokeWidth = 2
    ..color = Colors.black;

  final ui.ParagraphBuilder strokeBuilder =
      ui.ParagraphBuilder(ui.ParagraphStyle(
    textAlign: TextAlign.left,
    fontSize: fontSize,
    fontWeight: FontWeight.values[fontWeight],
    textDirection: TextDirection.ltr,
  ))
        ..pushStyle(ui.TextStyle(
          foreground: strokePaint,
        ))
        ..addText(content.text);

  return strokeBuilder.build()
    ..layout(ui.ParagraphConstraints(width: danmakuWidth));
}