getName<T> static method

String getName<T>(
  1. T enumValue, {
  2. String recase(
    1. String value
    ) = reCase,
})

Returns the Enum name without the enum class. e.g. DayName.Wednesday becomes Wednesday. By default we recase the value to Title Case. You can pass an alternate method to control the format.

Implementation

static String getName<T>(T enumValue,
    {String Function(String value) recase = reCase}) {
  String name = enumValue.toString();
  int period = name.indexOf('.');

  return recase(name.substring(period + 1));
}