Man of few words said, directly on the code:
package_info: ^0.4.0+16 path_provider: ^1.6.5 open_file: ^3.0.1 url_launcher: ^5.4.2
_Update () the async { IF (Platform.isIOS) { // String URL = // '? ITMS-Apps: MT = //itunes.apple.com/cn/app/id414478124. 8'; // this is the address of the micro-letter , the address to be replaced when their application // IF (the await canLaunch (URL)) { // the await Launch (URL); // } the else { // the throw 'Could Not Launch $ URL'; // } } the else IF (Platform.isAndroid) { URL String = HttpUtils.VERSION_URL + 'App-release.apk' ; the try { // / store files created Directory = StorageDir the await getExternalStorageDirectory (); String storagePath = storageDir.path; File _apkFile = await downloadAndroid(storagePath,url); OpenFile.open("${storagePath}/app-release.apk"); } catch (e) { print ( '$ {e}' ); } } } // / download update packages Andrews Future <File> downloadAndroid (StoragePath String, String URL) the async { File file = new File('$storagePath/app-release.apk'); if (!file.existsSync()) { file.createSync(); } try { print("-------------333333333333"); Function tr = throttle((List args){ print("-----------------------6666"); int count = args[0]; int total = args[1]; double radio = count/total; String str = (_progress_val*100).toInt().toString(); setState(() { _progress_val = radio; _progress = "download progress: STR $ {}%" ; }); }, 500 ); // / downloading request to initiate the Response Response = the await Dio () GET (URL,. onReceiveProgress: (int count,int total){ // tr([count,total]); double radio = count/total; String str = (_progress_val*100).toInt().toString(); setState(() { _progress_val = radio; _progress = "download progress: STR $ {}%" ; }); }, options: Options( responseType: ResponseType.bytes, followRedirects: false, )); file.writeAsBytesSync(response.data); return file; } catch (e) { print (e); } }