MarkdownStyleSheet.fromTheme constructor

MarkdownStyleSheet.fromTheme(
  1. ThemeData theme
)

Creates a MarkdownStyleSheet from the TextStyles in the provided ThemeData.

Implementation

factory MarkdownStyleSheet.fromTheme(ThemeData theme) {
  assert(theme.textTheme.bodyText2?.fontSize != null);
  return MarkdownStyleSheet(
    a: const TextStyle(color: Colors.blue),
    p: theme.textTheme.bodyText2,
    code: theme.textTheme.bodyText2!.copyWith(
      backgroundColor: theme.cardTheme.color ?? theme.cardColor,
      fontFamily: 'monospace',
      fontSize: theme.textTheme.bodyText2!.fontSize! * 0.85,
    ),
    h1: theme.textTheme.headline5,
    h2: theme.textTheme.headline6,
    h3: theme.textTheme.subtitle1,
    h4: theme.textTheme.bodyText1,
    h5: theme.textTheme.bodyText1,
    h6: theme.textTheme.bodyText1,
    em: const TextStyle(fontStyle: FontStyle.italic),
    strong: const TextStyle(fontWeight: FontWeight.bold),
    del: const TextStyle(decoration: TextDecoration.lineThrough),
    blockquote: theme.textTheme.bodyText2,
    img: theme.textTheme.bodyText2,
    checkbox: theme.textTheme.bodyText2!.copyWith(
      color: theme.primaryColor,
    ),
    blockSpacing: 8.0,
    listIndent: 24.0,
    listBullet: theme.textTheme.bodyText2,
    listBulletPadding: const EdgeInsets.only(right: 4),
    tableHead: const TextStyle(fontWeight: FontWeight.w600),
    tableBody: theme.textTheme.bodyText2,
    tableHeadAlign: TextAlign.center,
    tableBorder: TableBorder.all(
      color: theme.dividerColor,
      width: 1,
    ),
    tableColumnWidth: const FlexColumnWidth(),
    tableCellsPadding: const EdgeInsets.fromLTRB(16, 8, 16, 8),
    tableCellsDecoration: const BoxDecoration(),
    blockquotePadding: const EdgeInsets.all(8.0),
    blockquoteDecoration: BoxDecoration(
      color: Colors.blue.shade100,
      borderRadius: BorderRadius.circular(2.0),
    ),
    codeblockPadding: const EdgeInsets.all(8.0),
    codeblockDecoration: BoxDecoration(
      color: theme.cardTheme.color ?? theme.cardColor,
      borderRadius: BorderRadius.circular(2.0),
    ),
    horizontalRuleDecoration: BoxDecoration(
      border: Border(
        top: BorderSide(
          width: 5.0,
          color: theme.dividerColor,
        ),
      ),
    ),
  );
}