[英]How to change the selected ListTile Icon and Text color in Flutter?
[英]flutter: change default Icon text color
我在我的应用程序上修改了 textTheme 主题数据:
ThemeData get lightTheme => ThemeData(
disabledColor: AppColors.disabled,
scaffoldBackgroundColor: AppColors.paper,
textTheme: TextTheme(
button: AppTextStyles.button,
overline: AppTextStyles.overline,
),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ButtonStyle(
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppSize.s32),
),
),
backgroundColor: MaterialStateProperty.resolveWith(
(final states) => states.contains(MaterialState.disabled)
? 50.gray
: 500.primary,
),
),
),
我也使用了这段代码,但没有奏效:
elevatedButtonTheme: ElevatedButtonThemeData(
style: ButtonStyle(
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppSize.s32),
),
),
backgroundColor: MaterialStateProperty.resolveWith(
(final states) => states.contains(MaterialState.disabled)
? 50.gray
: 500.primary,
),
textStyle: MaterialStateProperty.resolveWith(
(final states) {
return const TextStyle(color: Color(0xFF661F1F));
},
),
),
),
这是AppTextStyles.button,
static final TextStyle _base = GoogleFonts.inder(
color: Colors.black,
fontWeight: FontWeight.w600,
);
static final button = _base.copyWith(
fontSize: 16.sp, fontWeight: FontWeight.w700, color: Colors.black);
但是当我添加ElevatedButton
时,文本颜色仍然是白色?
ElevatedButton.icon(
onPressed: () {},
icon: Icon(Icons.access_alarm),
label: Text("Sign in")),
这是我的材料:
GetMaterialApp(
theme: AppThemes().lightTheme,
使用 ButtonStyle 的foregroundColor 属性。
foregroundColor: MaterialStateProperty.all(Colors.black)
尝试更改ButtonStyle
内foregroundColor
的颜色。
foregroundColor: MaterialStateProperty.resolveWith(
(final states) => states.contains(MaterialState.disabled)
? Colors.grey
: Color(0xFF661F1F),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.