toSnakeCase property
String
get
toSnakeCase
Converts the string to snake_case.
Example:
print('helloWorld'.toSnakeCase); // hello_world
Implementation
String get toSnakeCase {
return replaceAllMapped(RegExp(r'(?<=[a-z])[A-Z]'), (Match m) => '_${m.group(0)}')
.toLowerCase()
.replaceAll(RegExp(r'[\s-]+'), '_');
}