updateLauncherName method

  1. @override
void updateLauncherName()
override

Implementation

@override
void updateLauncherName() {
  if (!common.fileExists(context.androidManifestPath)) {
    common.logSkipped(
      "Android launcher name",
      context.androidManifestPath,
      "file does not exist",
    );
    return;
  }

  final manifestFileData = common.readFile(context.androidManifestPath);
  final desiredBundleName = common.fetchLauncherName(context);
  final escapedDesiredName =
      common.escapeForDoubleQuotedString(desiredBundleName);

  final updatedManifestData = common.replaceFirstMatchOrThrow(
    manifestFileData,
    RegExp(r'android:label\s*=\s*"[^"]*"'),
    (_) => 'android:label="$escapedDesiredName"',
    "android:label",
    context.androidManifestPath,
  );

  common.overwriteFile(context.androidManifestPath, updatedManifestData);
}