getBlockQuote method

  1. @override
Future<List<Widget>> getBlockQuote(
  1. String line, [
  2. TextStyle? style
])
override

Implementation

@override
Future<List<pw.Widget>> getBlockQuote(String line, [pw.TextStyle? style]) async {
  final List<pw.Widget> widgets = <pw.Widget>[];
  final pw.TextStyle defaultStyle = pw.TextStyle(color: PdfColor.fromHex("#808080"));
  final pw.TextStyle blockquoteStyle = blockQuoteTextStyle ?? defaultStyle;
  final Iterable<RegExpMatch> matches = Constant.BLOCKQUOTE_PATTERN.allMatches(line);
  for (int i = 0; i < matches.length; i++) {
    final RegExpMatch match = matches.elementAt(i);
    final String content = match.group(1)!;
    final String fixedContent = content
        .decodeSymbols.convertUTF8QuotesToValidString; //we must to replace this, because the issue comes to coverter from delta to html|
    final List<pw.InlineSpan> spans = await _getStylesSpans(fixedContent);
    widgets.add(
      pw.Container(
        width: pageWidth,
        padding: const pw.EdgeInsets.only(left: 10, right: 10, top: 5, bottom: 5),
        decoration: pw.BoxDecoration(
          color: this.blockQuoteBackgroundColor ?? PdfColor.fromHex('#fbfbf9'),
          border: pw.Border(
            left: pw.BorderSide(
              color: blockQuoteDividerColor ?? PdfColors.blue,
              width: blockQuotethicknessDividerColor ?? 2.5,
            ),
          ),
        ),
        child: pw.RichText(
          softWrap: true,
          overflow: pw.TextOverflow.span,
          text: pw.TextSpan(
            style: blockquoteStyle,
            children: <pw.InlineSpan>[...spans],
          ),
        ),
      ),
    );
  }
  return widgets;
}