File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -182,12 +182,24 @@ extension ConversionExt on Object? {
182182 }
183183
184184 /// Converts given object to [ColorRGBA] if possible. Returns null otherwise.
185- ColorRGBA ? toColorRGBA () {
185+ ColorRGBA ? toColorRGBA ([ double alpha = 1.0 ] ) {
186186 final value = this ;
187187 if (value == null ) return null ;
188188 if (value is ColorRGBA ) return value;
189189 if (value is String ) return ColorRGBA .fromHex (value);
190- if (value is ColorRGB ) return value.toColorRGBA ();
190+ if (value is ColorRGB )
191+ return ColorRGBA (r: value.r, g: value.g, b: value.b, a: alpha);
192+
193+ return null ;
194+ }
195+
196+ /// Converts given object to [ColorRGB] if possible. Returns null otherwise.
197+ ColorRGB ? toColorRGB () {
198+ final value = this ;
199+ if (value == null ) return null ;
200+ if (value is ColorRGB ) return value;
201+ if (value is String ) return ColorRGB .fromHex (value);
202+ if (value is ColorRGBA ) return ColorRGB (r: value.r, g: value.g, b: value.b);
191203
192204 return null ;
193205 }
You can’t perform that action at this time.
0 commit comments