typeToId static method

String typeToId(
  1. dynamic type
)

Implementation

static String typeToId(dynamic type) {
  String value = '';
  if (type.runtimeType == Type) {
    value = type.toString();
  }

  RegExp exp = RegExp(r'(?<=[a-z])[A-Z]');
  String typeId = value
      .replaceAllMapped(exp, (Match m) => ('_${m.group(0)}'))
      .toLowerCase();
  if (typeId.endsWith('_model')) {
    typeId = typeId.substring(0, typeId.length - 6);
  }

  return typeId;
}