Home > other >  What's the difference between withOpacity() and withAlpha() methods
What's the difference between withOpacity() and withAlpha() methods

Time:09-11

I want to know what's the main difference between the withAlpha() and withOPacity() methods for the Color object, and when should I use each one in my code

CodePudding user response:

According to the flutter documentation found in the following links :

https://api.flutter.dev/flutter/dart-ui/Color/withAlpha.html

https://api.flutter.dev/flutter/dart-ui/Color/withOpacity.html

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

withOpacity() Returns a new color that matches this color with the alpha channel replaced with the given opacity (which ranges from 0.0 to 1.0).

the deference is with how much range (levels) of this color (the color you are using) you can apply.

  • Related