Pattern.fromString constructor
Pattern.fromString(
- String stringDescription
Instantiate a Pattern from a String representation in the form of "pattern_backgroundHex_foregroundHex".
Implementation
factory Pattern.fromString(String stringDescription) {
var splitDescription = stringDescription.split("_");
PatternType patternType = PatternType.values.firstWhere(
(e) => e.toString() == 'PatternType.' + splitDescription.first);
Color bgColor = hexOrRGBToColor('#' + splitDescription[1]);
Color fgColor = hexOrRGBToColor('#' + splitDescription.last);
return Pattern.fromValues(
patternType: patternType, bgColor: bgColor, fgColor: fgColor);
}