Skip to content

Commit 7f0373a

Browse files
committed
improve toHex method.
1 parent 4f57ef2 commit 7f0373a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/src/api/models/color_rgba.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ class ColorRGBA with EquatableMixin, SerializableMixin {
112112
}
113113

114114
/// Converts this [ColorRGBA] to [ColorRGB] by removing the alpha channel.
115-
String toHex() {
115+
String toHex({bool opaque = false, bool includeHash = true}) {
116116
final r = (this.r * 255).toInt().toRadixString(16).padLeft(2, '0');
117117
final g = (this.g * 255).toInt().toRadixString(16).padLeft(2, '0');
118118
final b = (this.b * 255).toInt().toRadixString(16).padLeft(2, '0');
119119
final a = (this.a * 255).toInt().toRadixString(16).padLeft(2, '0');
120-
return '#$a$r$g$b'.toUpperCase();
120+
return '${includeHash ? '#' : ''}${opaque ? '' : a}$r$g$b'.toUpperCase();
121121
}
122122

123123
@override

0 commit comments

Comments
 (0)