What are the advantages of using theme extension for storing custom colors instead of class containing static consts?
class AppColors {
static const Color brandColor = Color(0xFF1E88E5);
static const Color danger = Color(0xFFE53935);
//...
}
vs
@immutable
class MyColors extends ThemeExtension<MyColors> {
const MyColors({
required this.brandColor,
required this.danger,
});
//...
}
//...
final MyColors myColors = Theme.of(context).extension<MyColors>()!;
One advantages for class is that it does not require context. What are the prons of theme extensions?