convertToString static method Null safety

String convertToString(
  1. dynamic enumItem,
  2. {bool camelCase = false}
)

Convert an enum to a string

Pass in the enum value, so TestEnum.valueOne into enumItem It will return the striped off value so "valueOne".

If you pass in the option camelCase=true it will convert it to words So TestEnum.valueOne will become Value One

Implementation

static String convertToString(dynamic enumItem, {bool camelCase = false}) {
  assert(enumItem != null);
  assert(_isEnumItem(enumItem),
      '$enumItem of type ${enumItem.runtimeType.toString()} is not an enum item');
  final _tmp = enumItem.toString().split('.')[1];
  return !camelCase ? _tmp : camelCaseToWords(_tmp);
}