在使用flutter_markdown时,是否有办法更改文本的字体大小?类似于向Text小部件提供TextStyle那样。谢谢!
Markdown(
data: html2md.convert(article.content),
styleSheet: MarkdownStyleSheet.fromTheme(Theme.of(context))
.copyWith(
p: Theme.of(context).textTheme.body1.copyWith(fontSize: 12.0)
),
)
您可以在Markdown中覆盖特定元素的文本样式,上面的代码示例用于覆盖Markdown中的p
元素(在html中为<p>
元素)。
2021年样式主文本的方法是:
Markdown(
data: "This is the *way*",
styleSheet: MarkdownStyleSheet.fromTheme(ThemeData(
textTheme: TextTheme(
bodyText2: TextStyle(
fontSize: 20.0, color: Colors.green)))))),
以下代码会调整所有元素中的文本大小:
Markdown(
styleSheet: MarkdownStyleSheet.fromTheme(Theme.of(context))
.copyWith(textScaleFactor: 1.5),
data: md,
);
theme:new ThemeData(
backgroundColor: Colors.black26,primarySwatch: Colors.grey,
textTheme: TextTheme(body1: TextStyle(fontSize: 25.0),
headline: TextStyle(fontSize: 25.0),title: TextStyle(fontSize: 30.0))
),
p: theme.textTheme.body1,
h1 theme.textTheme.headline,
h2: theme.textTheme.title,
h3: theme.textTheme.subhead,
h4: theme.textTheme.body2,
h5: theme.textTheme.body2,
h6: theme.textTheme.body2,