Flutter:flutter_markdown字体大小

nyp*_*ogi 4 markdown flutter

使用flutter_markdown时是否可以更改文本的字体大小?类似于将TextStyle提供给Text小部件。谢谢!

Chr*_*ian 14

2021 年,主要文本的样式设置方法是:

Markdown(
    data: "This is the *way*",
    styleSheet: MarkdownStyleSheet.fromTheme(ThemeData(
      textTheme: TextTheme(
          bodyText2: TextStyle(
              fontSize: 20.0, color: Colors.green)))))),
Run Code Online (Sandbox Code Playgroud)


k2s*_*k2s 8

以下代码在所有元素中缩放文本大小:

Markdown(
  styleSheet: MarkdownStyleSheet.fromTheme(Theme.of(context))
      .copyWith(textScaleFactor: 1.5),
  data: md,
);
Run Code Online (Sandbox Code Playgroud)


小智 7

Markdown(
    data: html2md.convert(article.content)
    ,styleSheet: MarkdownStyleSheet.fromTheme(Theme.of(context)).copyWith(p: Theme.of(context).textTheme.body1.copyWith(fontSize: 12.0)),
    )
Run Code Online (Sandbox Code Playgroud)

您可以覆盖markdown中spesific元素的文本样式,上面示例中的代码可以覆盖pmarkdown中的<p>元素(html中的元素)