Skip to content

Instantly share code, notes, and snippets.

@GAM3RG33K
Created April 28, 2025 08:00
Show Gist options
  • Save GAM3RG33K/85e17a8e7081d8bee88d8203d69bc84f to your computer and use it in GitHub Desktop.
Save GAM3RG33K/85e17a8e7081d8bee88d8203d69bc84f to your computer and use it in GitHub Desktop.
Flutter String Utils - All Time useful
extension StringExtensions on String? {
String? get capitalize {
if (this == null) return null;
final firstLetter = this![0].toUpperCase();
final rest = this!.substring(1);
return '$firstLetter$rest';
}
String? get toLowerSnackCase {
if (this == null) return null;
// Replace all non-alphanumeric characters with underscores, then lowercase
return this!.replaceAll(RegExp(r'[^a-zA-Z0-9]'), '_').toLowerCase();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment