toClassName static method
Converts a string (typically a database table or column name) to a Dart class name convention (PascalCase or UpperCamelCase).
An optional prefix
and/or suffix
can be added to the generated class name.
Examples:
StringUtils.toClassName("user_profiles") // "UserProfiles"
StringUtils.toClassName("user_profiles", prefix: "Db") // "DbUserProfiles"
StringUtils.toClassName("categories", suffix: "Table") // "CategoriesTable"
Implementation
static String toClassName(String name, {String? prefix, String? suffix}) {
final className = ReCase(name).pascalCase;
return '${prefix ?? ''}$className${suffix ?? ''}';
}