load static method

RenameConfig load()

Loads the configuration from the YAML file.

This method reads the flutter_app_identity configuration from pubspec.yaml and validates the required fields.

Returns a RenameConfig instance with the loaded values. Throws an exception if required fields are missing or invalid.

Implementation

static RenameConfig load() {
  final cfg = loadFlutterRenameConfig();
  final name = cfg['name'];
  if (name == null) throw Exception('flutter_app_identity.name is required');

  final shortName = cfg['shortName'] ?? name;
  final id = cfg['id'];
  final android = cfg['droidAppId'];
  final ios = cfg['iosAppId'];

  if (id != null && (android != null || ios != null)) {
    throw Exception('Use either id OR droidAppId + iosAppId');
  }
  if (id == null && (android == null || ios == null)) {
    throw Exception('Provide id or both droidAppId + iosAppId');
  }

  final androidId = id ?? android;
  final iosId = id ?? ios;

  validateBundleId(androidId);
  validateBundleId(iosId);

  return RenameConfig(
    name: name,
    shortName: shortName,
    androidId: androidId,
    iosId: iosId,
  );
}