When defining theme data, what should I use - primarySwatch or primaryColor?
Can they be used together?
And finaly, what's the difference between them?
ThemeData(
primarySwatch: kBaseColor,
brightness: Brightness.light,
primaryColor: kBaseColor,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
primaryColor has a type Color with shade[500] of primarySwatch, that itself has type MaterialColor.
Preferable to use primarySwatch to let app define different shades for its components.
This is a code fragment how theme colors are defined in theme_data.dart (material library):
final Brightness _brightness = brightness ?? colorScheme?.brightness ?? Brightness.light;
final bool isDark = _brightness == Brightness.dark;
primaryColor ??= isDark ? Colors.grey[900]! : primarySwatch;
primaryColorLight ??= isDark ? Colors.grey[500] : primarySwatch[100]!
toggleableActiveColor ??= isDark ? Colors.tealAccent[200]! : (accentColor ?? primarySwatch[600]!);
secondaryHeaderColor ??= isDark ? Colors.grey[700]! : primarySwatch[50]!;
textSelectionHandleColor ??= isDark ? Colors.tealAccent[400]! : primarySwatch[300]!;
and so on.
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