getColorFromRGBString function
Implementation
Color? getColorFromRGBString(String? color) {
if (color == null) return null;
if (color == "") return null;
if (color.startsWith("rgba")) {
color =
color.replaceAll('rgba', '').replaceAll('(', '').replaceAll(')', '');
var stageRgbColorSplited = color.split(',').map((e) {
return double.parse(e);
}).toList();
return Color.fromARGB(
(255 * stageRgbColorSplited[3]).round(),
stageRgbColorSplited[0].round(),
stageRgbColorSplited[1].round(),
stageRgbColorSplited[2].round());
}
color = color.replaceAll('rgb', '').replaceAll('(', '').replaceAll(')', '');
var stageRgbColorSplited = color.split(',').map((e) {
return int.parse(e);
}).toList();
Color stageColor = Color.fromRGBO(stageRgbColorSplited[0],
stageRgbColorSplited[1], stageRgbColorSplited[2], 1.0);
return stageColor;
}