swapColorString static method

dynamic swapColorString(
  1. dynamic value
)

Implementation

static dynamic swapColorString(dynamic value) {
  if (value is String) {
    final hexColorRegExp = RegExp(r'^#([A-Fa-f0-9]{8})$');
    if (hexColorRegExp.hasMatch(value)) {
      String lastTwoChars = value.substring(value.length - 2);
      String withoutLastTwoChars = value.substring(0, value.length - 2);
      return '#' + lastTwoChars + withoutLastTwoChars.substring(1);
    }
    return value;
  }
  return value;
}