launchApp static method
Launches an app by its package name (if it's installed).
packageName is the package identifier of the app to launch.
Returns true if launch was successful, otherwise throws an exception.
Implementation
static Future<bool> launchApp(String packageName) async {
try {
final result = await _channel.invokeMethod<bool>(
'launchApp',
{'packageName': packageName},
);
return result ?? false;
} on PlatformException catch (e) {
if (e.code == 'APP_NOT_FOUND') {
throw Exception('App not found: ${e.message}');
} else {
throw Exception('Failed to launch app: ${e.message}');
}
}
}