ensureAppId method

Future<String> ensureAppId()

Ensures that the app id exists in the pubspec.yaml file.

If the app id does not exist, it is generated and saved to the pubspec.yaml file. If it exists, the existing value is returned.

Returns the app id.

Implementation

Future<String> ensureAppId() async {
  final appId = Uuid().v4();
  final pubspec = _pubspecManager.load();

  if (pubspec['inno_build']['app_id'] == null) {
    pubspec['inno_build']['app_id'] = appId;
    _pubspecManager.save(pubspec);
    return appId;
  } else {
    return pubspec['inno_build']['app_id'] as String;
  }
}