Created
April 28, 2025 08:00
-
-
Save GAM3RG33K/85e17a8e7081d8bee88d8203d69bc84f to your computer and use it in GitHub Desktop.
Flutter String Utils - All Time useful
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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