I am using a progress bar,
I want it to change the bar color depending on the result of the division of two numbers, to do so I created a Custom Function
, and it works as it should, now I want it to use the Theme of my app, and I don't know how, this is what I have so far:
//... default flutterflow imports
Color getBarColor(
double dividend,
double divisor,
) {
/// MODIFY CODE ONLY BELOW THIS LINE
double res = dividend / divisor;
if (res < 0.5) {
return Colors.red;
} else if (res < 1) {
return Colors.yellow;
} else {
return Colors.green;
}
/// MODIFY CODE ONLY ABOVE THIS LINE
}
I tried (unfortunately) to access the theme using the line ThemeData theme = Theme.of(context);
, but it didn't work, It seems custom functions are just static and pure functions that have access to no context.
So, my question is, how can I solve this inconvenience?
Thank you in advance y'all