getAppName method
Fetches the app name from the Windows main.cpp file.
Returns: Future<String?>, the app name if found, null otherwise.
Implementation
@override
Future<String?> getAppName() async {
final filePath = windowsAppPath;
var contentLineByLine = await readFileAsLineByline(
filePath: filePath,
);
for (var i = 0; i < contentLineByLine.length; i++) {
if (contentLineByLine[i]?.contains('window.CreateAndShow') ?? false) {
var match = RegExp(r'CreateAndShow\(L"(.*?)"')
.firstMatch(contentLineByLine[i]!);
return match?.group(1)?.trim();
} else if (contentLineByLine[i]?.contains('window.Create') ?? false) {
var match =
RegExp(r'Create\(L"(.*?)"').firstMatch(contentLineByLine[i]!);
return match?.group(1)?.trim();
}
}
return null;
}