In iOS native development, I can define a dynamic color for using in both dark and light mode like this:
[UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull trait) {
if (trait.userInterfaceStyle == UIUserInterfaceStyleDark) {
return UIColorRGB(0x000000);
} else {
return UIColorRGB(0xFFFFFF);
}
}];
In Flutter, I know I can set these two colors into the MaterialApp's theme and darkTheme color property which will do the same thing. But the ThemeData's color property count is not infinite. And I don't think the color I want to create has something to do with the property name, like primaryColor or canvasColor and so on (in fact the color I want create may be used only once in the app).
So what is the best practice in Flutter to manage colors for light and dark mode?