generateStrokeParagraph static method

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

Implementation

static generateStrokeParagraph(
    DanmakuContentItem content, double danmakuWidth, double fontSize) {
  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,
    textDirection: TextDirection.ltr,
  ))
        ..pushStyle(ui.TextStyle(
          foreground: strokePaint,
        ))
        ..addText(content.text);

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