LocaleGenParams.fromYamlString constructor

LocaleGenParams.fromYamlString(
  1. String programName,
  2. String pubspecContent
)

Implementation

LocaleGenParams.fromYamlString(this.programName, String pubspecContent) {
  final doc = loadYaml(pubspecContent) as YamlMap;
  final projectName = doc['name'] as String?;

  if (projectName == null || projectName.isEmpty) {
    throw Exception(
        'Could not parse the pubspec.yaml, project name not found');
  }

  this.projectName = projectName;
  final config = doc[programName] as YamlMap?;
  if (config == null) {
    languages = ['en'];
    defaultLanguage = 'en';
    docLanguages = languages;
    return;
  }
  configure(config);
}