constantize method

String constantize()

Converts a string into a constant name.

Implementation

String constantize() {
  if (this == null) {
    throw ArgumentError('string: $this');
  }
  if (this!.isEmpty) {
    return '';
  }
  return this!.toUpperCase().replaceAll(RegExp(r'[^a-zA-Z0-9]'), '_');
}