setAppName method

  1. @override
Future<String?> setAppName({
  1. required String appName,
})
override

Sets the app name in the Linux CMakeLists.txt file.

Parameters:

  • appName: The new app name to be set for the application.

Returns: Future<String?>, a success message indicating the change in app name.

Implementation

@override
Future<String?> setAppName({required String appName}) async {
  final filePath = linuxCMakeListsPath;
  List? contentLineByLine = await readFileAsLineByline(
    filePath: filePath,
  );
  for (var i = 0; i < contentLineByLine.length; i++) {
    if (contentLineByLine[i].contains('set(BINARY_NAME')) {
      contentLineByLine[i] = 'set(BINARY_NAME \"$appName\")';
      break;
    }
  }
  final message = await super.setAppName(appName: appName);
  await writeFile(
    filePath: filePath,
    content: contentLineByLine.join('\n'),
  );
  return message;
}