如何解决如何在flutter中普遍更改应用栏的字体系列?
我想在我的应用程序中普遍更改应用程序栏字体,但我没有找到我正在寻找的任何合适的答案。
有没有办法在 MaterialApp 中使用 ThemeData 和主题全局应用主题?
我不想像下面这样应用 TextStyle 属性
appBar: AppBar(
title: Text('Title ',style: TextStyle(fontFamily: 'YOUR_FONT_FAMILY'),),
如果没有,更改应用栏字体的最佳方法是什么?
P.S. 这是我在 StackOverflow 上的第一篇文章。
解决方法
您应该使用AppBarTheme
。请找到以下代码
在 MaterialApp 中像这样使用,
MaterialApp(
title: 'Test App',debugShowCheckedModeBanner: false,theme: ThemeData(
appBarTheme: AppBarTheme(
textTheme: ThemeData.light()
.textTheme
.copyWith(
headline6: TextStyle( // instead of title use can use display as well
fontFamily: 'Lobster',),)
.apply(
fontFamily: 'Lobster',);
AppBar(
title: Text('App bar',style: Theme.of(context).appBarTheme.textTheme. headline6,);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。