getNewLinesWithSpacing method

Future<List<TextSpan>> getNewLinesWithSpacing(
  1. String line, [
  2. TextStyle? style
])

Implementation

Future<List<pw.TextSpan>> getNewLinesWithSpacing(String line, [pw.TextStyle? style]) async {
  final List<pw.TextSpan> spans = <pw.TextSpan>[];
  final Iterable<RegExpMatch> matches = Constant.NEWLINE_WITH_SPACING_PATTERN.allMatches(line);
  for (int i = 0; i < matches.length; i++) {
    final RegExpMatch match = matches.elementAt(i);
    final double? spacing = double.tryParse(match.group(2)!);
    final String content = match.group(3)!;
    final pw.TextStyle decided_style = style?.copyWith(
          lineSpacing: spacing?.resolveLineHeight(),
        ) ??
        defaultTextStyle.copyWith(lineSpacing: spacing?.resolveLineHeight());
    spans.add(pw.TextSpan(text: content.convertUTF8QuotesToValidString.decodeSymbols, style: decided_style));
  }
  return spans;
}