Config.fromFile constructor
Config.fromFile({})
Creates a Config instance directly from the pubspec.yaml
file.
Provides a convenient way to load configuration without manual JSON parsing.
Implementation
factory Config.fromFile({
BuildType type = BuildType.debug,
bool app = true,
bool installer = true,
required String? buildArgs,
required String? appVersion,
required String? signToolName,
required String? signToolCommand,
required String? signToolParams,
}) {
const filePath = 'pubspec.yaml';
final yamlMap = loadYaml(File(filePath).readAsStringSync()) as Map;
// yamlMap has the type YamlMap, which has several unwanted side effects
final yamlConfig = yamlToMap(yamlMap as YamlMap);
return Config.fromJson(
yamlConfig,
type: type,
app: app,
installer: installer,
buildArgs: buildArgs,
appVersion: appVersion,
signToolName: signToolName,
signToolCommand: signToolCommand,
signToolParams: signToolParams,
);
}