Reputation: 5942
I modified textTheme theme data on my application :
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,
:
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.icon(
onPressed: () {},
icon: Icon(Icons.access_alarm),
label: Text("Sign in")),
This is my material:
GetMaterialApp(
theme: AppThemes().lightTheme,
Upvotes: 0
Views: 691
Reputation: 652
try change color in foregroundColor
inside ButtonStyle
.
foregroundColor: MaterialStateProperty.resolveWith(
(final states) => states.contains(MaterialState.disabled)
? Colors.grey
: Color(0xFF661F1F),
Upvotes: 0
Reputation: 48
Use the foregroundColor property of the ButtonStyle.
foregroundColor: MaterialStateProperty.all(Colors.black)
Upvotes: 2