Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages

Free tool · Developer tools

Flutter color converter

This Flutter color converter changes a web color into the value Flutter expects. The CSS color #E76F51CC becomes Color(0xCCE76F51): the same four bytes, with the alpha CC moved from the end to the front.

  • Free
  • No sign-up
  • Runs in your browser

By Maaz Zindani · Updated

Type #E76F51CC, 0xCCE76F51, Color(0xFFE76F51), Color.fromARGB(255, 231, 111, 81), Color.fromRGBO(231, 111, 81, 0.8) or rgb(231, 111, 81).

Flutter color

Color(0xCCE76F51)Alpha 204 (CC), red 231, green 111, blue 81

  • Read as CSS hex, alpha last
  • Opacity 80%
  • CSS #E76F51CC
  • Flutter ColorColor(0xCCE76F51)
  • Color.fromARGBColor.fromARGB(204, 231, 111, 81)
  • Color.fromRGBOColor.fromRGBO(231, 111, 81, 0.8)
  • CSS hex (alpha last)#E76F51CC
  • CSS rgba()rgba(231, 111, 81, 0.8)

Flutter writes alpha first (AARRGGBB). CSS writes it last (RRGGBBAA). The swatch sits on a light and a dark half so transparency shows.

How to use the Flutter Color Converter (Hex to Color 0xFF)

  1. Type or paste a color into Color in any format, or use Pick for a color from your screen palette.
  2. Leave Opacity override empty to keep the alpha that came with the color, or type a percent to replace it.
  3. Read the notes under the swatch. They flag a value that Flutter would draw as fully transparent.
  4. Copy the line you need, for example Color(0x...) or Color.fromARGB, and paste it into your widget code.

How do I convert a hex color to a Flutter Color?

A Flutter Color holds four 8-bit channels packed into one 32-bit integer, written in hex as 0xAARRGGBB: alpha, red, green, blue. A web hex color lists red, green and blue first and puts an optional alpha at the end. For the sample #E76F51CC the bytes are E7, 6F, 51 and CC, which are red 231, green 111, blue 81 and alpha 204. Reordered for Flutter they read Color(0xCCE76F51).

Moving the alpha is the whole job, and it is the step people miss when they paste #E76F51CC after 0x. The result 0xE76F51CC reads as alpha E7, red 6F, green 51 and blue CC, which is a different and wrong color. The page reads the input in the format it was written in and writes all the Flutter forms at once, so no byte is shifted by hand.

Without an alpha in the web color, the result is fully opaque. The plain #E76F51 becomes Color(0xFFE76F51), where FF is alpha 255.

Why does my Flutter color show up transparent?

The usual cause is a six-digit value after 0x. Flutter takes the low 32 bits of the integer, and a six-digit number leaves the top byte, the alpha, at zero. The page reads 0xE76F51 literally and reports alpha 0. Its note says: Flutter reads 0xE76F51 as alpha 00, which is fully transparent. For the opaque color write 0xFFE76F51.

To make a color translucent, pick an alpha between 0 and 255. The table lists common opacity steps, with the alpha as a number, as the two hex digits that go right after 0x, and as the opacity double that Color.fromRGBO takes. Half opacity is 128, which is 80 in hex, and not 7F, because 255 times 0.5 is 127.5 and the page rounds to the nearest step. Typing 50 into the opacity field turns the sample into Color(0x80E76F51).

Opacity as Flutter alpha
OpacityAlpha (0 to 255)Hex pairOpacity double
100%255FF1.0
90%230E60.9
80%204CC0.8
70%179B30.7
60%153990.6
50%128800.5
40%102660.4
30%774D0.3
20%51330.2
10%261A0.1
0%0000.0

Which constructor does a Flutter color converter write: Color(), fromARGB or fromRGBO?

All three build the same object. Color(int) takes the packed value, which is short and easy to copy from a design file once the alpha is in front. Color.fromARGB takes four integers from 0 to 255, so the sample is Color.fromARGB(204, 231, 111, 81). Color.fromRGBO takes red, green and blue as integers and the opacity as a double from 0.0 to 1.0, giving Color.fromRGBO(231, 111, 81, 0.8) for the same color. The Flutter documentation describes the first two with 8-bit channels and the third with an opacity.

fromRGBO reads best when the design says a percentage, such as 50 percent: Color(0x80E76F51) is the packed value for Color.fromRGBO(231, 111, 81, 0.5). The opacity double is chosen by the page as the shortest number that returns to the same alpha, so alpha 204 shows as 0.8 and alpha 1 needs three decimals, 0.004.

Plain CSS values work as inputs and as outputs. The sample as CSS is #E76F51CC or rgba(231, 111, 81, 0.8), and #E76F51 is its opaque form. A value the page cannot read gets a message instead of a guess: for #E76F5 it says "A CSS hex color has 3, 4, 6 or 8 digits, and "E76F5" has 5."

Use it with

Questions

How do I convert a hex color to a Flutter color?

Put 0xFF in front of the six hex digits for an opaque color, so #E76F51 becomes Color(0xFFE76F51). With an alpha, move it to the front: #E76F51CC becomes Color(0xCCE76F51).

Why is #RRGGBBAA different from 0xAARRGGBB?

CSS puts the alpha last and Flutter puts it first. The four bytes are the same, only the order changes.

What does Color(0xFFFFFF) draw?

Nothing visible. A six-digit value has alpha 00, so Flutter reads it as fully transparent. Write 0xFFFFFFFF for opaque white.

How do I set 50 percent opacity?

Alpha is 128 for 50 percent, written 0x80. Type 50 in the opacity field to get Color(0x80E76F51) for the sample.

Can it read Color.fromARGB or rgba()?

Yes. Paste Color.fromARGB, Color.fromRGBO, Color(0x...), a 0x value, a CSS hex color or rgb() and rgba(). All the Flutter and CSS forms are written back.

Is my color sent to a server?

No. The page does the arithmetic locally and sends nothing anywhere.

The tool's results are computed in your browser by the code on this page, using the sources listed above; the explanations are checked against the tool's own output.