flavorName static method
Validates a single flavor name. Must be lowercase, alphanumeric +
underscores, start with a letter, and not be a reserved word
(main, test, or a Dart keyword) — flavor names become Dart enum
constants and Gradle product flavors.
Implementation
static String? flavorName(String input) {
final trimmed = input.trim();
if (trimmed.isEmpty) return 'Flavor name cannot be empty.';
if (!StringUtils.isValidPackageName(trimmed) || trimmed == 'main') {
return 'Invalid flavor "$input". '
'Use lowercase letters, numbers, and underscores; '
'must start with a letter; not a reserved word (main, test). '
'Example: dev';
}
return null;
}