Docs: https://api.flutter.dev/flutter/material/Switch-class.html
How do I change the border Color when the Switch is turned off? In Material 3, when it is on, the border color is the same as the Switch background color, but when it is off, it has a border. How do I change it in Material 3?

Code:
Switch(
trackColor: (miniVerbose)
? const MaterialStatePropertyAll(Colors.greenAccent)
: const MaterialStatePropertyAll(Colors.orange),
value: miniVerbose,
onChanged: (value) {
setState(() {
miniVerbose = value;
});
},
),
flutter 3.10 add trackOutlineColor for Switch
trackOutlineColor: MaterialStateProperty.resolveWith(
(final Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) {
return null;
}
return AppColors.slateGray;
},
),
use this code:
theme: ThemeData(
useMaterial3: true,
).copyWith(
colorScheme:
Theme.of(context).colorScheme.copyWith(outline: Colors.orange),
),
Switch:
Switch(
value: value,
activeTrackColor: Colors.orange,
inactiveTrackColor: Colors.yellow,
activeColor: Colors.yellow,
onChanged: (_) => setState(() => value = !value),
),

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With