Last active
March 3, 2022 18:13
-
-
Save Sorbh/4533d87e27e6dcd61598c2cf585940f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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