In Flutter documentation, it's given
The 开发者_如何学CMaterial widgets
Switch
,SwitchListTile
,Checkbox
,CheckboxListTile
,Radio
,RadioListTile
now useColorScheme.secondary
color for their toggleable widget.ThemeData.toggleableActiveColor
is deprecated and will eventually be removed.
But CheckboxListTile is using ColorScheme.primary
for the toggleableActiveColor
instead of ColorScheme.secondary
My Main Theme:
ThemeData(
material3 : true,
colorScheme: ColorScheme.fromSeed(
seedColor: DesignColor.green,
primary: DesignColor.green,
onPrimary: DesignColor.primaryTextColor,
secondary: DesignColor.yellow,
onSecondary: DesignColor.white))
My CheckboxListTile:
CheckboxListTile(
controlAffinity: ListTileControlAffinity.leading,
title: Text(range999),
value: values[1],
onChanged: (val) {})
Output:
Note: The documentation works if i remove usematerial3:true
there is a checkboxTheme
property inside ThemeData
.
You can update something like this.
checkboxTheme: CheckboxThemeData(
fillColor: MaterialStateProperty.all<Color>(Colors.purple),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(3),
),
side: BorderSide(color: Colors.grey.shade100, width: 1.5),
),
Happy coding:)
精彩评论