In Android I could do this in my colors.xml
:
<color name="my_custom_blue">#F7DC16</color>
In Flutter the only way to reuse colors is to define them in the Theme. However I want to define my custom colors with custom names so I can use it like this:
color: Colors.myCustomBlue
Anybody know how to achieve this?
I would suggest you create your own custom colors in another file:
class Colors {
static const Color myCustomBlack = const Color(0x8A000000);
static const Color white = const Color(0xFFFFFFFF);
}
but if you want to use them in your project, with CupertinoColors there is no conflict but with material Colors, you should either change the class name to something like MyColors which I think is better or you can hide the Colors class from the Material Library. if you want to use them just import the dart file and you are good to go.
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