使用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)
以下代码在所有元素中缩放文本大小:
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中的元素)
| 归档时间: |
|
| 查看次数: |
1107 次 |
| 最近记录: |