简体   繁体   English

flutter:更改默认图标文本颜色

[英]flutter: change default Icon text color

I modified textTheme theme data on my application:我在我的应用程序上修改了 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,
        ),
 
      ),
    ),

I Used this code too but not worked:我也使用了这段代码,但没有奏效:

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));
      },
    ),
  ),
),

This is AppTextStyles.button, :这是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);

But when I added ElevatedButton the text color is still white?但是当我添加ElevatedButton时,文本颜色仍然是白色?

      ElevatedButton.icon(
          onPressed: () {},
          icon: Icon(Icons.access_alarm),
          label: Text("Sign in")),

This is my material:这是我的材料:

GetMaterialApp(
          theme: AppThemes().lightTheme,

在此处输入图像描述

Use the foregroundColor property of the ButtonStyle.使用 ButtonStyle 的foregroundColor 属性。
foregroundColor: MaterialStateProperty.all(Colors.black)

try change color in foregroundColor inside ButtonStyle .尝试更改ButtonStyleforegroundColor的颜色。

foregroundColor: MaterialStateProperty.resolveWith(
            (final states) => states.contains(MaterialState.disabled)
                ? Colors.grey
                : Color(0xFF661F1F),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM