MarkdownStyleSheet.fromCupertinoTheme constructor

MarkdownStyleSheet.fromCupertinoTheme(
  1. CupertinoThemeData theme
)

Creates a MarkdownStyleSheet from the TextStyles in the provided CupertinoThemeData.

Implementation

factory MarkdownStyleSheet.fromCupertinoTheme(CupertinoThemeData theme) {
  assert(theme.textTheme.textStyle.fontSize != null);
  return MarkdownStyleSheet(
    a: theme.textTheme.textStyle.copyWith(
      color: theme.brightness == Brightness.dark
          ? CupertinoColors.link.darkColor
          : CupertinoColors.link.color,
    ),
    p: theme.textTheme.textStyle,
    pPadding: EdgeInsets.zero,
    code: theme.textTheme.textStyle.copyWith(
      backgroundColor: theme.brightness == Brightness.dark
          ? CupertinoColors.systemGrey6.darkColor
          : CupertinoColors.systemGrey6.color,
      fontFamily: 'monospace',
      fontSize: theme.textTheme.textStyle.fontSize! * 0.85,
    ),
    h1: theme.textTheme.textStyle.copyWith(
      fontWeight: FontWeight.w500,
      fontSize: theme.textTheme.textStyle.fontSize! + 10,
    ),
    h1Padding: EdgeInsets.zero,
    h2: theme.textTheme.textStyle.copyWith(
      fontWeight: FontWeight.w500,
      fontSize: theme.textTheme.textStyle.fontSize! + 8,
    ),
    h2Padding: EdgeInsets.zero,
    h3: theme.textTheme.textStyle.copyWith(
      fontWeight: FontWeight.w500,
      fontSize: theme.textTheme.textStyle.fontSize! + 6,
    ),
    h3Padding: EdgeInsets.zero,
    h4: theme.textTheme.textStyle.copyWith(
      fontWeight: FontWeight.w500,
      fontSize: theme.textTheme.textStyle.fontSize! + 4,
    ),
    h4Padding: EdgeInsets.zero,
    h5: theme.textTheme.textStyle.copyWith(
      fontWeight: FontWeight.w500,
      fontSize: theme.textTheme.textStyle.fontSize! + 2,
    ),
    h5Padding: EdgeInsets.zero,
    h6: theme.textTheme.textStyle.copyWith(
      fontWeight: FontWeight.w500,
    ),
    h6Padding: EdgeInsets.zero,
    em: theme.textTheme.textStyle.copyWith(
      fontStyle: FontStyle.italic,
    ),
    strong: theme.textTheme.textStyle.copyWith(
      fontWeight: FontWeight.bold,
    ),
    del: theme.textTheme.textStyle.copyWith(
      decoration: TextDecoration.lineThrough,
    ),
    blockquote: theme.textTheme.textStyle,
    img: theme.textTheme.textStyle,
    checkbox: theme.textTheme.textStyle.copyWith(
      color: theme.primaryColor,
    ),
    blockSpacing: 8,
    listIndent: 24,
    listBullet: theme.textTheme.textStyle,
    listBulletPadding: const EdgeInsets.only(right: 4),
    tableHead: theme.textTheme.textStyle.copyWith(
      fontWeight: FontWeight.w600,
    ),
    tableBody: theme.textTheme.textStyle,
    tableHeadAlign: TextAlign.center,
    tableBorder: TableBorder.all(color: CupertinoColors.separator, width: 0),
    tableColumnWidth: const FlexColumnWidth(),
    tableCellsPadding: const EdgeInsets.fromLTRB(16, 8, 16, 8),
    tableCellsDecoration: BoxDecoration(
      color: theme.brightness == Brightness.dark
          ? CupertinoColors.systemGrey6.darkColor
          : CupertinoColors.systemGrey6.color,
    ),
    blockquotePadding: const EdgeInsets.all(16),
    blockquoteDecoration: BoxDecoration(
      color: theme.brightness == Brightness.dark
          ? CupertinoColors.systemGrey6.darkColor
          : CupertinoColors.systemGrey6.color,
      border: Border(
        left: BorderSide(
          color: theme.brightness == Brightness.dark
              ? CupertinoColors.systemGrey4.darkColor
              : CupertinoColors.systemGrey4.color,
          width: 4,
        ),
      ),
    ),
    codeblockPadding: const EdgeInsets.all(8),
    codeblockDecoration: BoxDecoration(
      color: theme.brightness == Brightness.dark
          ? CupertinoColors.systemGrey6.darkColor
          : CupertinoColors.systemGrey6.color,
    ),
    horizontalRuleDecoration: BoxDecoration(
      border: Border(
        top: BorderSide(
          color: theme.brightness == Brightness.dark
              ? CupertinoColors.systemGrey4.darkColor
              : CupertinoColors.systemGrey4.color,
        ),
      ),
    ),
  );
}