readAppIdentifier function

String readAppIdentifier(
  1. Directory appDirectory,
  2. FlutterPlatform platform, {
  3. String configFileName = ProjectConfigFileConstants.defaultFileName,
})

Reads the app identifier the Flutter app in appDirectory declares for platform: the iOS bundle ID of the Xcode project's Runner app target, or the Android application ID of the app module's Gradle build file.

Throws FailureException if the file holding it is missing, declares no identifier, declares more than one, as an app with flavors does, takes it from a variable or another unquoted value, or declares Flutter's com.example placeholder. Its hint says the identifier can be set in the project configuration file configFileName instead. Throws ArgumentError for a platform that apps cannot be published for.

Implementation

String readAppIdentifier(
  Directory appDirectory,
  FlutterPlatform platform, {
  String configFileName = ProjectConfigFileConstants.defaultFileName,
}) {
  return switch (platform) {
    FlutterPlatform.ios => _readBundleId(appDirectory, configFileName),
    FlutterPlatform.android => _readApplicationId(appDirectory, configFileName),
    FlutterPlatform.linux ||
    FlutterPlatform.macos ||
    FlutterPlatform.windows => throw ArgumentError.value(
      platform,
      'platform',
      'has no app identifier to publish with',
    ),
  };
}