toSnakeCase method
Implementation
String toSnakeCase() =>
this
?.replaceAllMapped(RegExp(r'[A-Z]'), (m) => '_${m[0]!.toLowerCase()}')
.replaceAll(' ', '_')
.replaceAll(RegExp(r'__+'), '_')
.trim()
.replaceAll(RegExp(r'^_|_$'), '') ??
'';