getAdjustColor static method

Color getAdjustColor(
  1. Color baseColor,
  2. int amount
)

Implementation

static Color getAdjustColor(Color baseColor, int amount) {
  var colors = <String, int>{
    'red': baseColor.red,
    'green': baseColor.green,
    'blue': baseColor.blue,
  };
  colors = colors.map((key, value) {
    if (value + amount < 0) return MapEntry(key, 0);
    if (value + amount > 255) return MapEntry(key, 255);
    return MapEntry(key, value + amount);
  });
  return Color.fromRGBO(colors['red']!, colors['green']!, colors['blue']!, 1);
}