Created
November 22, 2021 23:10
-
-
Save SamJakob/58c714a29126551e9e83a1487cf7d035 to your computer and use it in GitHub Desktop.
Snakes and Camels!
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
/// Converts an upper camel case string to lower snake case. | |
String toLowerSnake(String value) { | |
return value.replaceAllMapped(RegExp(r"([A-Z])"), (match) => "_${match.group(1)!.toLowerCase()}"); | |
} | |
/// Converts a lower snake case string to upper camel case. | |
String toUpperCamel(String value) { | |
return value.replaceAllMapped(RegExp(r"_([a-z])"), (match) => match.group(1)!.toUpperCase()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment