Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed color alpha value calculation in getColor function #200

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ibrahim-Lokman
Copy link

Problem

The getColor method incorrectly scaled the alpha value (color?.a) from a range of 0 to 1 by multiplying it by 255 and converting it to an integer. This resulted in an invalid alpha value for CSS, which expects the alpha channel to remain in the range of 0 to 1.

Solution

  • Adjusted the calculation to directly use color?.a without scaling.
  • Ensured the alpha value remains within the valid CSS rgba range.

Changes Made

  • Removed the multiplication by 255 for the alpha channel.
  • Updated the getColor function to correctly calculate and return the CSS-compatible rgba string.

Impact

With this fix, opacity set in Flutter now works correctly after the CSS conversion.

Note

This issue was present in earlier versions of the flutter_tex package (prior to 4.0.10) and could have been avoided by using color?.opacity instead of color?.alpha.

Updated file: lib/src/utils/style_utils.dart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant