How to Use Different Color Formats Hex ARGB RGBO in Flutter Dart

There are basically 4 types of color formats supported by Flutter which is Hex Color code, ARGB, RGBA and Color constants. App developer can define color in all formats according to his requirement. In this tutorial we would learn about all there colors formats and how to Use Different Color Formats Hex ARGB RGBO in Flutter Dart Android iOS mobile application.

List of Color all Formats:

1. Hex Color code : Hex color code is used with prefix ( 0xff + Hex color code ) format. Here first character is Zero.

Example: Color(0xFF42A5F5)  .

2. ARGB Color code : Alpha Red Green Blue Color code. ARGB color code is define with Color.fromARGB(Pass Color Integer Value) function.

Example :  Color.fromARGB(255, 255, 128, 0)  .

3. RGBA Color code : RGBA also known as Red Green Blue Alpha color code is defined using Color.fromRGBO(Pass Color Int Value) function.

Example : Color.fromRGBO(0, 155, 0, 1.0)  .

4. Color constants : Flutter comes with 53 inbuilt color constants. We would use Colors library with . Dot operator to define color constants.

Example : Colors.red 

Contents in this project How to Use Different Color Formats Hex ARGB RGBO in Flutter Dart:

1. Import material.dart package in main.dart file.

2. Call our main MyApp class using void main runApp().

3. Create our main MyApp class extends with State less widget.

4. Create Scaffold widget -> Safe Area widget -> Center widget -> Column widget.

5. Create 4 Text widget with 4 different color formats.

6. Complete source code for main.dart file:

Screenshot:

Use Different Color Formats Hex ARGB RGBO in Flutter Dart

Leave a Reply

Your email address will not be published.