Rgb.from constructor
Rgb.from(
- Object? source
Creates an instance of Rgb color by converting the specified source
object.
If a CSS Color Module Level 3 source
string is specified, it is parsed
and then converted to the RGB color space. See Color.parse for examples.
If a color instance is specified, it is converted to the RGB color space
using Color.rgb. Note that unlike Color.rgb this method always returns
a new instance, even if color is already an RGB color.
Implementation
factory Rgb.from(Object? source) {
if (source is String) source = Color.tryParse(source);
if (source is! Color) {
return Rgb(double.nan, double.nan, double.nan, double.nan);
}
return source.rgb().copy();
}