getLineGradient static method

LinearGradient getLineGradient(
  1. String color
)

Implementation

static LinearGradient getLineGradient(String color) {
  final String str = color.replaceAll('linear-gradient(', '');
  final String splitText = str.substring(0, str.length - 1);
  final List<String> strList = splitText.split(RegExp(r',(?![^()]*\))'));
  List<String> colorArr;
  if (strList[0].indexOf('top') != -1 ||
      strList[0].indexOf('left') != -1 ||
      strList[0].indexOf('right') != -1 ||
      strList[0].indexOf('bottom') != -1) {
    colorArr = strList.sublist(1);
  } else {
    colorArr = strList;
  }
  return LinearGradient(colors: colorArr.map((e) => HexColor(e)).toList());
}