ClonifySettings.fromYaml constructor

ClonifySettings.fromYaml(
  1. YamlMap yaml
)

Creates a ClonifySettings instance from a YAML map.

Parses the YAML configuration file and creates a settings object. Provides default values for missing optional fields.

Example:

final yaml = loadYaml('''
firebase:
  enabled: true
  settings_file: firebase_settings.yaml
company_name: My Company
default_color: '#FF5733'
''');
final settings = ClonifySettings.fromYaml(yaml);

Implementation

factory ClonifySettings.fromYaml(YamlMap yaml) {
  // Parse custom fields if they exist
  List<CustomField> customFields = [];
  if (yaml['custom_fields'] != null) {
    final fields = yaml['custom_fields'] as YamlList;
    customFields = fields
        .map((field) => CustomField.fromYaml(field as Map<dynamic, dynamic>))
        .toList();
  }

  return ClonifySettings(
    firebaseEnabled: yaml['firebase']['enabled'] ?? false,
    firebaseSettingsFilePath: yaml['firebase']['settings_file'] ?? '',
    fastlaneEnabled: yaml['fastlane']['enabled'] ?? false,
    fastlaneSettingsFilePath: yaml['fastlane']['settings_file'] ?? '',
    companyName: yaml['company_name'] ?? '',
    defaultColor: yaml['default_color'] ?? '#FFFFFF',
    needsLauncherIcon: yaml['needs_launcher_icon'] ?? false,
    needsSplashScreen: yaml['needs_splash_screen'] ?? false,
    needsLogo: yaml['needs_logo'] ?? false,
    customFields: customFields,
  );
}