james-alex / flutter_color_models

A wrapper for the Dart color_models plugin with added support for Flutter's Color class.
https://pub.dev/packages/flutter_color_models
BSD 2-Clause "Simplified" License
9 stars 1 forks source link

Bug hsb with brightness #1

Open GROOVIZ opened 3 years ago

GROOVIZ commented 3 years ago

The current implementation does not update the brightness of HSB colors:

@override
HsbColor withBrightness(num value) {
  assert(value != null && value >= 0 && value <= 100);

  return HsbColor(hue, saturation, brightness, alpha);
}

I changed it to follow what you did on other withXYZ methods, i.e. shadowing the instance variable:

@override
HsbColor withBrightness(num brightness) {
  assert(brightness!= null && brightness>= 0 && brightness<= 100);

  return HsbColor(hue, saturation, brightness, alpha);
}

A better solution could be to use value for the incoming parameter:

@override
HsbColor withBrightness(num value) {
  assert(value != null && value >= 0 && value <= 100);

  return HsbColor(hue, saturation, value, alpha);
}