getStatusColor static method
Returns color which represents HTTP status. Brighter colors are used in
dark mode and darker ones in light mode to keep text readable.
Implementation
static Color getStatusColor(BuildContext context, int? status) {
final bool isDark = Theme.of(context).brightness == Brightness.dark;
final Color neutral = Theme.of(context).colorScheme.onSurfaceVariant;
return switch (status) {
-1 => isDark ? red : darkRed,
int status when status >= 200 && status < 300 =>
isDark ? green : darkGreen,
int status when status >= 300 && status < 400 =>
isDark ? orange : darkOrange,
int status when status >= 400 && status < 600 => isDark ? red : darkRed,
_ => neutral,
};
}