Config.fromFile constructor

Config.fromFile({
  1. BuildType type = BuildType.debug,
  2. bool app = true,
  3. bool installer = true,
  4. required String? buildArgs,
  5. required String? appVersion,
  6. required String? signToolName,
  7. required String? signToolCommand,
  8. required String? signToolParams,
})

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,
  );
}