You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Considering Color.fromRGBA instead of fromARGB #5205
To more easily leverage the color converters out there, and existing docs around color and the web, Flutter could consider thinking in "RGBA" instead of "ARGB".
(not sure if there was a reason we went with ARGB?)
CSS doesn't have a way to provide ARGB as a single hex code, does it? Just rgba(.., .., .., ...).
In which case we could have const Color(0xAARRGGBB) and new Color.fromRGBA(rr, gg, bb, aa), where the former is significantly preferred but the latter is available when you need to switch from CSS to Flutter.
The same developer also commented that our handling of Alpha as a byte instead of a float felt odd coming from a CSS background. So fromRGBA might need to be (byte, byte, byte, float) to feel like CSS.
We're inconsistent about where we use a byte or a float. We should make sure we're consistent. (Typically we call the float "opacity" and the byte "alpha" but I'm not sure how consistent we are about that.)
I think we should use that convention in general but in this specific case I think we should still call it fromRGBA (not fromRGBO or fromRgbAndOpacity) because then it matches CSS, which is the point.
The documentation for that method should only refer to the fourth argument as the "opacity" though.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
sethladd commentedon Aug 3, 2016
cc @Hixie
abarth commentedon Aug 3, 2016
Is the "instead" part important or would Color.fromRGBA in addition to Color.fromARGB be acceptable?
It's how Skia prefers to pack the bits.
a14n commentedon Aug 4, 2016
Having two really close names (
fromRGBAandfromARGB) with the same types for parameters could be error prone IMHO.Hixie commentedon Aug 4, 2016
CSS doesn't have a way to provide ARGB as a single hex code, does it? Just
rgba(.., .., .., ...).In which case we could have
const Color(0xAARRGGBB)andnew Color.fromRGBA(rr, gg, bb, aa), where the former is significantly preferred but the latter is available when you need to switch from CSS to Flutter.eseidelGoogle commentedon Aug 4, 2016
The same developer also commented that our handling of Alpha as a byte instead of a float felt odd coming from a CSS background. So fromRGBA might need to be (byte, byte, byte, float) to feel like CSS.
Hixie commentedon Aug 4, 2016
Agreed.
abarth commentedon Aug 4, 2016
We're inconsistent about where we use a byte or a float. We should make sure we're consistent. (Typically we call the float "opacity" and the byte "alpha" but I'm not sure how consistent we are about that.)
Hixie commentedon Aug 4, 2016
I think we should use that convention in general but in this specific case I think we should still call it fromRGBA (not fromRGBO or fromRgbAndOpacity) because then it matches CSS, which is the point.
The documentation for that method should only refer to the fourth argument as the "opacity" though.
1 remaining item
abarth commentedon Sep 19, 2016
@Hixie says
Color.fromRGBOis the one true name.abarth commentedon Sep 19, 2016
Not sure how to get from opacity (which is a double) to the internal representation (which is an int) as a const expression...
A Color.fromRGBO
A Color.fromRGBO
A Color.fromRGBO
A Color.fromRGBO (#3043)
github-actions commentedon Sep 6, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.A Color.fromRGBO (flutter-team-archive/engine#3043)