Flutter 你能改变颤振文本主题吗?
如果主题在main.dart中设置为Flutter 你能改变颤振文本主题吗?,flutter,material-design,flutter-web,flutter-theme,Flutter,Material Design,Flutter Web,Flutter Theme,如果主题在main.dart中设置为 return MaterialApp( title: 'MY APP', theme: ThemeData( primarySwatch: Colors.blue, fontFamily: 'Cabin', textTheme: TextTheme( headline1: TextStyle( fontFamily: 'Raleway', color: Colors.black,
return MaterialApp(
title: 'MY APP',
theme: ThemeData(
primarySwatch: Colors.blue,
fontFamily: 'Cabin',
textTheme: TextTheme(
headline1: TextStyle(
fontFamily: 'Raleway',
color: Colors.black,
fontWeight: FontWeight.w600,
fontSize: 18,
),
subtitle1: TextStyle(
fontFamily: 'Raleway',
color: Colors.black54,
fontWeight: FontWeight.w600,
fontSize: 16,
),
),
),
我把这个主题当作
Text('MY STRING',
style: Theme.of(context).textTheme.subtitle1),
如何使“我的字符串”的颜色与副标题1的主题颜色不同,同时保留主题数据的其他属性,如字体大小、系列和大小等?您可以使用de方法copyWithcolor:your_color来更改TextTheme的属性
例如:
Text('MY STRING',
style: Theme.of(context).textTheme.subtitle1
.copyWith(color: Colors.red),
)
文档参考:您可以使用de方法copyWithcolor:your_color来更改文本主题的属性
例如:
Text('MY STRING',
style: Theme.of(context).textTheme.subtitle1
.copyWith(color: Colors.red),
)
参考医生:正是我想要的,谢谢。不客气!正是我想要的,谢谢。不客气!