You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ran across this issue and wrote my own helper function to get around it. Thought I'd share here in case anyone else found it useful.
StringcolorToHexCode(Color color, {ignoreTransparency =false}) {
// takes in a number from 0-255 and converts it to the equivalent Hex valueStringrgbValueToHexValue(intnum) {
assert(num<=255&&num>=0);
if (num==0) {
return"00";
}
const hexChars ="0123456789ABCDEF";
final val = (num/16);
final firstVal = val.floor().toInt();
final secondVal = (val.remainder(firstVal) *16).toInt();
return"${hexChars[firstVal]}${hexChars[secondVal]}";
}
var result ="#${rgbValueToHexValue(color.red)}${rgbValueToHexValue(color.green)}${rgbValueToHexValue(color.blue)}";
if (color.opacity <1.0&&!ignoreTransparency) {
final numVal = (255* color.opacity).round();
result +=rgbValueToHexValue(numVal);
return result;
}
return result;
}
The text was updated successfully, but these errors were encountered: