setAppName method
Sets the app name in the iOS Info.plist 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 = iosInfoPlistPath;
List? contentLineByLine = await readFileAsLineByline(
filePath: filePath,
);
for (var i = 0; i < contentLineByLine.length; i++) {
if (contentLineByLine[i].contains('<key>CFBundleName</key>')) {
contentLineByLine[i + 1] = '\t<string>$appName</string>\r';
break;
}
}
for (var i = 0; i < contentLineByLine.length; i++) {
if (contentLineByLine[i].contains('<key>CFBundleDisplayName</key>')) {
contentLineByLine[i + 1] = '\t<string>$appName</string>\r';
break;
}
}
final message = await super.setAppName(appName: appName);
var writtenFile = await writeFile(
filePath: filePath,
content: contentLineByLine.join('\n'),
);
return message;
}