tagnote-app / markdown_viewer

A Markdown viewer widget for Flutter. It renders Markdown string to rich text output.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Default style should default to Theme.of(context).textTheme.bodyMedium

JCKodel opened this issue · comments

Currently, the default text style doesn't reflect the current app theme.

The idea is to exchange Text("something") with MarkdownViewer("something") and have the exact same output.

In my projects, I had to create a wrapper for it:

class Markdown extends StatelessWidget {
  const Markdown(this.text, {this.style, super.key});

  final String text;
  final TextStyle? style;

  @override
  Widget build(BuildContext context) {
    return MarkdownViewer(
      text,
      selectable: false,
      styleSheet: MarkdownStyle(
        textStyle: style ?? Theme.of(context).textTheme.bodyMedium,
      ),
    );
  }
}

Thanks for your feedback. I might add a static method fromTheme(ThemeData theme) to MarkdownStyle later.