tinycolor icon indicating copy to clipboard operation
tinycolor copied to clipboard

setAlpha and setOpacity have no effect

Open nfriend opened this issue 4 years ago • 3 comments

Summary

The setAlpha and setOpacity methods don't seem to have any effect on the TinyColor instance.

Possible cause

Looking at the source, I believe this is because these methods are defined like this:

TinyColor setAlpha(int alpha) {
  _color.withAlpha(alpha);
  return this;
}

However, the withAlpha method returns a new Color instance:

Returns a new color that matches this color with the alpha channel replaced with a (which ranges from 0 to 255).

so this doesn't actually change _color.

nfriend avatar Feb 22 '21 00:02 nfriend

I just encounter the same issue. For workaround, do .color.withOpacity() or .color.withAlpha().…

calvintam236 avatar Jun 17 '21 11:06 calvintam236

Hey @nfriend, can you resubmit this issue to community-forked repo? Thanks!

calvintam236 avatar Jun 24 '21 20:06 calvintam236

@calvintam236 Done! https://github.com/FooStudio/tinycolor/issues/14

nfriend avatar Jun 24 '21 20:06 nfriend