fromRGBHexString static method

Paint fromRGBHexString(
  1. String hexString
)

Parses an RGB color from a valid hex string (e.g. #1C1C1C).

The # is optional. The short-hand syntax is support, e.g.: #CCC. Lower-case letters are supported.

Examples of valid inputs: ccc, CCC, #ccc, #CCC, #c1c1c1, #C1C1C1, c1c1c1, C1C1C1

If the string is not valid, an error is thrown.

Note: if you are hardcoding colors, use Dart's built-in hexadecimal literals instead.

Implementation

static Paint fromRGBHexString(String hexString) {
  final color = ColorExtension.fromRGBHexString(hexString);
  return Paint()..color = color;
}