fromStringToInt<T> static method

int? fromStringToInt<T>(
  1. List<T> enumValues,
  2. String value
)

Implementation

static int? fromStringToInt<T>(List<T> enumValues, String value) {
  /// Returns the enum item from a [String] value.
  /// It receives a [List] of enum values and a [String] value as parameters.
  /// It returns the enum item.
  /// If the [value] is null, it returns null.
  for (var i = 0; i < enumValues.length; i++) {
    if (enumValues[i].toString().normalized() == value.normalized()) {
      return i + 1;
    }
  }

  return null;
}