This is in reference to a comment on question What's the best practice to keep all the constants in Flutter?
I want to define a separate file for my all color values as colors.dart
<data type> red = Colors.red (I am not sure of data tpye to be use here I mean String, Color or what)
<data type> cyan = hex code
and then use them directly with name as
TextStyle(
color: red,
fontSize: 24,
),
'red', 'green' as we do in Android.
I looked at many posts on S/O, and in most implementations, at the end we still need to use dot operator to access created variable, which is similar to using Colors.red, then purpose not solved of using short names like 'red'
Then I come across this comment by @ChinLoong (https://stackoverflow.com/a/64584504/12319976).
There ChinLoong talked exactly about the thing that was in my mind, however I am not sure how to use this approach exactly.
Since I could not comment there to ask(due to reputation points), I am asking here.
Also, I believe even with this enum approach, I still have to access color variable with dot operator. Even if I will create a function to return color, again, dot operator.
My entire rigidness and determination anyhow is to avoid use of dot syntax while using colors. Just red or green.
Kindly let me know is there any way at all.
Thank you.