generateWidget method

Future<Widget?> generateWidget({
  1. DeltaAttributesOptions? deltaOptionalAttr,
  2. double? maxWidth,
  3. double? maxHeight,
  4. bool overrideAttributesPassedByUser = false,
  5. void onException(
    1. dynamic error
    )?,
  6. bool shouldProcessDeltas = true,
})

Implementation

Future<pw.Widget?> generateWidget({
  qpdf.DeltaAttributesOptions? deltaOptionalAttr,
  double? maxWidth,
  double? maxHeight,
  bool overrideAttributesPassedByUser = false,
  void Function(dynamic error)? onException,
  bool shouldProcessDeltas = true,
}) async {
  deltaOptionalAttr ??= qpdf.DeltaAttributesOptions.common();
  final qpdf.Converter<Delta, pw.Document> converter = qpdf.PdfService(
    pageFormat: pageFormat,
    fonts: globalFontsFallbacks,
    onRequestBoldFont: onRequestBoldFont,
    onRequestBothFont: onRequestBoldItalicFont,
    customTheme: themeData,
    customBuilders: customBuilders,
    blockQuoteBackgroundColor: blockQuoteBackgroundColor,
    blockQuoteDividerColor: blockQuoteDividerColor,
    codeBlockBackgroundColor: codeBlockBackgroundColor,
    codeBlockFont: codeBlockFont,
    codeBlockNumLinesTextStyle: codeBlockNumLinesTextStyle,
    codeBlockTextStyle: codeBlockTextStyle,
    blockQuoteTextStyle: blockQuoteTextStyle,
    onRequestFallbacks: onRequestFallbackFont,
    onDetectAlignedParagraph: onDetectAlignedParagraph,
    onDetectCommonText: onDetectCommonText,
    onDetectBlockquote: onDetectBlockquote,
    onDetectCodeBlock: onDetectCodeBlock,
    blockQuotePaddingLeft: blockQuotePaddingLeft,
    blockQuotePaddingRight: blockQuotePaddingRight,
    blockQuotethicknessDividerColor: blockQuotethicknessDividerColor,
    onDetectHeaderBlock: onDetectHeaderBlock,
    onDetectImageBlock: onDetectImageBlock,
    onDetectInlineRichTextStyles: onDetectInlineRichTextStyles,
    onDetectLink: onDetectLink,
    onDetectList: onDetectList,
    onRequestFont: onRequestFont,
    backM: !shouldProcessDeltas
        ? backMatterDelta
        : processDelta(backMatterDelta, deltaOptionalAttr,
            overrideAttributesPassedByUser),
    frontM: !shouldProcessDeltas
        ? frontMatterDelta
        : processDelta(frontMatterDelta, deltaOptionalAttr,
            overrideAttributesPassedByUser),
    onRequestItalicFont: onRequestItalicFont,
    document: !shouldProcessDeltas
        ? document
        : processDelta(
            document, deltaOptionalAttr, overrideAttributesPassedByUser)!,
  );
  try {
    return await converter.generateWidget(
        maxWidth: maxWidth, maxHeight: maxHeight);
  } catch (e) {
    onException?.call(e);
    rethrow;
  }
}