Toolvito

Works on this device

Flutter Color Converter

Type a colour as in CSS, such as #3366cc or rgba(51, 102, 204, 0.5), and get the Flutter forms Color(0xFF3366CC), Color.fromARGB and Color.fromRGBO. Paste a Flutter colour to get the CSS hex and rgb() values. Or turn a list of named colours into a Dart class of constants. Nothing is run or sent.

Enter your values

Type a colour as in CSS. Get Color(0xAARRGGBB), Color.fromARGB and Color.fromRGBO for Flutter.

Your values

Hex such as #3366cc or #3366cc80, rgb(51, 102, 204), rgba(51, 102, 204, 0.5), hsl(220, 60%, 50%) or a name such as teal.

Your values are worked out in this browser. They are not sent to a server.

Your result will show here

Fill in the values, then choose Convert.

How to use the Flutter colour converter

  1. Choose CSS colour to Flutter and type a colour: hex (#3366cc, #3366cc80, f80), rgb(), rgba(), hsl() or a name such as teal.
  2. Copy Color(0x...), Color.fromARGB(...) or Color.fromRGBO(...) into your Dart code.
  3. To go back, choose Flutter to CSS and paste a Flutter colour.
  4. For a whole set, choose Palette to a Dart class, write one name and colour on each line, and copy the class.

How Flutter writes a colour

  • A Flutter Color is 32 bits: alpha (opacity), red, green and blue, each from 0 to 255, written as two hexadecimal digits. In 0xAARRGGBB the alpha comes first: 0xFF is solid and 0x00 is fully transparent.
  • CSS writes the alpha last: #3366cc80 is Color(0x803366CC) in Flutter.
  • Color.fromARGB(a, r, g, b) takes the same four numbers from 0 to 255.
  • Color.fromRGBO(r, g, b, opacity) takes an opacity from 0.0 to 1.0. Flutter before version 3.27 took the whole part of opacity × 255 as the alpha; later versions round it. The tool writes the shortest opacity for which both give the same alpha, so 128 is written as 0.502, not 0.5.
  • An opacity from CSS becomes the alpha round(opacity × 255): 0.5 is 128 (0x80) and 0.25 is 64 (0x40).
  • A common mistake: Color(0x3366CC) has only 6 digits, so its alpha is 00 and it is invisible. The tool warns about it.

Worked example

#3366cc: 33, 66 and CC in hexadecimal are 51, 102 and 204, and the colour is solid, so the alpha is FF (255). In Flutter it is Color(0xFF3366CC), Color.fromARGB(255, 51, 102, 204) or Color.fromRGBO(51, 102, 204, 1.0).

rgba(51, 102, 204, 0.5) has the alpha round(0.5 × 255) = 128 = 0x80: Color(0x803366CC) and Color.fromRGBO(51, 102, 204, 0.502).

Limits you should know

  • Colours are 8-bit sRGB. A colour outside sRGB, such as some oklch() colours, is clipped and marked.
  • Named Material colours such as Colors.blue and the newer Color.from(alpha:, red:, green:, blue:) are not read. Type the value instead.
  • For other colour codes (HSL, CMYK, CSS names), use the Color Code Converter.

Related tools