snakeCase method
Implementation
String snakeCase() {
if (this == null) {
return '';
}
String result = this!.replaceAllMapped(RegExp('([A-Z])'),
(Match match) => '_${match.group(0)?.toLowerCase()}');
result = result.replaceAll(' ', '_').toLowerCase();
if (result.startsWith('_')) {
result = result.substring(1);
}
return result;
}