FlavorGradle.from constructor
Derive gradle settings from a flavor name and the base app title.
prod is treated as the release flavor: no id/version suffix and the
bare app title. Every other flavor gets .<flavor> / -<flavor> suffixes
and a <Title> <Flavor> label.
Implementation
factory FlavorGradle.from(String flavor, String title) {
if (flavor == 'prod') {
return FlavorGradle(
name: flavor,
applicationIdSuffix: '',
versionNameSuffix: '',
appLabel: title,
);
}
final label = flavor
.split('_')
.map((s) => s.isEmpty ? '' : s[0].toUpperCase() + s.substring(1))
.join(' ');
return FlavorGradle(
name: flavor,
applicationIdSuffix: '.$flavor',
versionNameSuffix: '-$flavor',
appLabel: '$title $label',
);
}