Hombre de pocas palabras, dijo, directamente sobre el código:
package_info: ^ 0.4.0 + 16 path_provider: ^ 1.6.5 OPEN_FILE: ^ 3.0.1 url_launcher: ^ 5.4.2
_Update () del asíncrono { SI (Platform.isIOS) { // String url = // 'ITMS-Aplicaciones: MT = //itunes.apple.com/cn/app/id414478124 8?.'; // esta es la dirección de la micro-carta , la dirección a ser reemplazado cuando su aplicación // sI (el canLaunch await (URL)) { // el lanzamiento await (URL); // } else { // de banda 'no podría tener Lanzamiento $ URL'; // } } else SI {(Platform.isAndroid) String URL = HttpUtils.VERSION_URL + 'App-release.apk' ; el try { // archivos / tienda creada Directorio storageDir =await getExternalStorageDirectory (); Cadena StoragePath = storageDir.path; Presentar _apkFile = Await downloadAndroid (StoragePath, url); OpenFile.open ( "$ {} StoragePath /app-release.apk" ); } Catch (e) { print ( '$ {e}' ); } } } // /下载安卓更新包 Futuro <Archivo> downloadAndroid (String StoragePath, String url) {asíncrono del archivo = nuevo archivo ( '$ StoragePath / app-release.apk' ); si (! file.existsSync ()) { file.createSync (); } Tratar { print ( "------------- 333333333333" ); Función tr = acelerador ((Lista args) { print ( "----------------------- 6666" ); int count = args [0 ]; int totales = args [1 ]; doble de radio = cantidad / total, de cadena str = (* _progress_val 100 ) .toInt () toString ();. setstate (() { _progress_val = radio; _progress = "下载进度: $ {str}% " ; }); },500 ); responseType: ResponseType.bytes,// /发起下载请求 respuesta Respuesta = Await Dio () obtener (url,. OnReceiveProgress: ( int cuenta, int total) { // tr ([recuento, total]); doble de radio = Cantidad / total, String str = ( _progress_val * 100 ) .toInt (.) toString (); setstate (() { _progress_val = radio; _progress = "下载进度: $ {str}%" ; }); }, opciones: opciones ( followRedirects: , )) ;falsa file.writeAsBytesSync (response.data); devolver archivo; } Catch (e) { print (e); } }