downloadAndInstallApk method
Future<void>
downloadAndInstallApk({
- required String downloadFileUrl,
- void onError(
- String error
- void onProgress(
- double progress
- String? downloadFileName,
override
Implementation
@override
Future<void> downloadAndInstallApk({
required String downloadFileUrl,
void Function(String error)? onError,
void Function(double progress)? onProgress,
String? downloadFileName,
}) async {
try {
if (downloadFileUrl.trim().isEmpty) {
onError?.call("Download File Url is empty");
return;
}
await ApiService().downloadFile(
downloadFileUrl: downloadFileUrl,
downloadFileName: downloadFileName,
onSuccess: (filePath) async {
await _channel.invokeMethod<String>('downloadAndInstallApk', {
"path": filePath,
});
},
onError: (error) {
onError?.call(error);
},
onProgress: (progress) {
onProgress?.call(progress);
},
);
} on PlatformException catch (e, sc) {
printLog(e.toString(), stackTrace: sc);
if (onError != null) {
onError(e.message ?? "");
}
} catch (e, sc) {
printLog(e.toString(), stackTrace: sc);
onError?.call(e.toString());
}
}