I have used card widget and container both in one screen and set the white color in both and it’s display correct in container but not correct in card widget. I have attache the screenshot. in this screenshot code and emulator both are show for compared.
Thank you in advanced
Note I have used the App them for Light theme and dark theme.
ThemeData lightTheme(){
return ThemeData.light(useMaterial3: true).copyWith(
scaffoldBackgroundColor: Colors.white,
primaryColor: Colors.black,
primaryColorDark: Colors.white,
appBarTheme: AppBarTheme(
backgroundColor: Colors.white,
shadowColor: Colors.black,
elevation: 15,
foregroundColor: Colors.black,
titleTextStyle:TextStyle().copyWith(color: Colors.black,fontFamily: EAFontName.Muli,fontWeight: EAFontWeight.muliMedium),
),
textTheme: TextTheme(
titleSmall: TextStyle().copyWith(color: Colors.black,fontFamily: EAFontName.Muli,fontWeight: EAFontWeight.muliRegular,fontSize: EAFontSize.size10),
titleMedium: TextStyle().copyWith(color: Colors.black,fontFamily: EAFontName.Muli,fontWeight: EAFontWeight.muliSemiBold,fontSize: EAFontSize.size12),
titleLarge: TextStyle().copyWith(color: Colors.black,fontFamily: EAFontName.Muli,fontWeight: EAFontWeight.muliBold,fontSize: EAFontSize.size16),
),
bottomNavigationBarTheme: BottomNavigationBarThemeData(
backgroundColor: Colors.white54,
selectedItemColor: Colors.black,
unselectedItemColor: Colors.black54,
elevation: 16,
),
cardColor: Colors.white,
cardTheme: CardTheme(
color: Colors.white,
shadowColor: Colors.black,
elevation: 6,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
// side: BorderSide(color: Colors.black,width: 1)
),
),
);
}
ThemeData darkTheme(){
return ThemeData.light(useMaterial3: true).copyWith(
scaffoldBackgroundColor: Colors.black,
primaryColor: Colors.white,
primaryColorDark: Colors.black,
appBarTheme: AppBarTheme(
backgroundColor: Colors.black,
shadowColor: Colors.white,
elevation: 15,
foregroundColor: Colors.white,
titleTextStyle: TextStyle().copyWith(color: Colors.white,fontFamily: EAFontName.Muli,fontWeight: EAFontWeight.muliMedium),
),
textTheme: TextTheme(
titleSmall: TextStyle().copyWith(color: Colors.white,fontFamily: EAFontName.Muli,fontWeight: EAFontWeight.muliRegular,fontSize: EAFontSize.size10),
titleMedium: TextStyle().copyWith(color: Colors.white,fontFamily: EAFontName.Muli,fontWeight: EAFontWeight.muliSemiBold,fontSize: EAFontSize.size12),
titleLarge: TextStyle().copyWith(color: Colors.white,fontFamily: EAFontName.Muli,fontWeight: EAFontWeight.muliBold,fontSize: EAFontSize.size16),
),
bottomNavigationBarTheme: BottomNavigationBarThemeData(
backgroundColor: Colors.black54,
selectedItemColor: Colors.white,
unselectedItemColor: Colors.white54,
elevation: 16,
),
cardColor: Colors.black,
cardTheme: CardTheme(
color: Colors.black,
shadowColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
// side: BorderSide(color: Colors.white,width: 1)
),
elevation: 8
),
);
}
I have also try add Theme color to card widegts but same result getting.
Thank in advanced
2
Answers
I did a
quick and dirty
implementation of aCard
widget usingMaterial design
and it seems to be working fine and shows thewhite
color properly.Here is my code:
Output
Can you please check if any other
Theme
orcolor
is getting applied to yourWidget
.With
material 3
there is new option for this which issurfaceTintColor
add that to the card widget and set to what you want read more here for migrating to the material 3