Skip to content

Instantly share code, notes, and snippets.

@Sorbh
Last active March 3, 2022 18:13
Show Gist options
  • Save Sorbh/4533d87e27e6dcd61598c2cf585940f7 to your computer and use it in GitHub Desktop.
Save Sorbh/4533d87e27e6dcd61598c2cf585940f7 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
class HexColor extends Color {
static int _getColorFromHex(String hexColor) {
hexColor = hexColor.toUpperCase().replaceAll("#", "");
if (hexColor.length == 6) {
hexColor = "FF" + hexColor;
}
return int.parse(hexColor, radix: 16);
}
HexColor(final String hexColor) : super(_getColorFromHex(hexColor));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment