Generator constructor
Generator()
Creates a new generator with configuration from the 'pubspec.yaml' file.
Implementation
Generator() {
var pubspecConfig = PubspecConfig();
_key = pubspecConfig.key;
_className = defaultClassName;
if (pubspecConfig.className != null) {
if (isValidClassName(pubspecConfig.className!)) {
_className = pubspecConfig.className!;
} else {
warning(
"Config parameter 'class_name' requires valid 'UpperCamelCase' value.");
}
}
_mainLocale = defaultMainLocale;
if (pubspecConfig.mainLocale != null) {
if (isValidLocale(pubspecConfig.mainLocale!)) {
_mainLocale = pubspecConfig.mainLocale!;
} else {
warning(
"Config parameter 'main_locale' requires value consisted of language code and optional script and country codes separated with underscore (e.g. 'en', 'en_GB', 'zh_Hans', 'zh_Hans_CN').");
}
}
_arbDir = defaultArbDir;
if (pubspecConfig.arbDir != null) {
if (isValidPath(pubspecConfig.arbDir!)) {
_arbDir = pubspecConfig.arbDir!;
} else {
warning(
"Config parameter 'arb_dir' requires valid path value (e.g. 'lib', 'res/', 'lib\\l10n').");
}
}
_outputDir = defaultOutputDir;
if (pubspecConfig.outputDir != null) {
if (isValidPath(pubspecConfig.outputDir!)) {
_outputDir = pubspecConfig.outputDir!;
} else {
warning(
"Config parameter 'output_dir' requires valid path value (e.g. 'lib', 'lib\\generated').");
}
}
_useDeferredLoading =
pubspecConfig.useDeferredLoading ?? defaultUseDeferredLoading;
_otaEnabled =
pubspecConfig.localizelyConfig?.otaEnabled ?? defaultOtaEnabled;
}