tagnote-app / markdown_viewer

A Markdown viewer widget for Flutter. It renders Markdown string to rich text output.
BSD 3-Clause "New" or "Revised" License
16 stars 18 forks source link

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

Open JCKodel opened 1 year ago

JCKodel commented 1 year ago

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,
      ),
    );
  }
}
chenzhiguang commented 1 year ago

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