我的项目在调试模式下一切正常,但发布后,除了一个过程之外,其他都正常工作。
这是该过程:
Future<void> downloadFile() async{
Dio dio = Dio();
var directory = await getApplicationDocumentsDirectory();
await dio.download(bookUrl, "${directory.path}/$className + $bookName.pdf",
onReceiveProgress: (rec, total){
setState(() {
downloading = true;
percentage = ((rec/total) * 100).toStringAsFixed(0)+'%';
});
}
);
setState(() {
downloading = false;
percentage = 'Download Completed';
});
这是Release应用运行时我遇到的错误信息:
E/flutter (25796): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] 未处理的异常:DioError [DioErrorType.DEFAULT]:SocketException: Failed host lookup: 'www.ets.org' (OS Error: No address associated with hostname, errno = 7) E/flutter (25796): #0 Dio._makeRequest (package:dio/src/dio.dart:799) E/flutter (25796): E/flutter (25796): #1 Dio._request.. (package:dio/src/dio.dart:711) E/flutter (25796): #2 _rootRunUnary (dart:async/zone.dart:1132) E/flutter (25796): #3 _CustomZone.runUnary (dart:async/zone.dart:1029) E/flutter (25796): #4 _FutureListener.handleValue (dart:async/future_impl.dart:126) E/flutter (25796): #5
Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639) E/flutter (25796): #6
Future._propagateToListeners (dart:async/future_impl.dart:668) E/flutter (25796): #7 Future._complete (dart:async/future_impl.dart:473) E/flutter (25796): #8
_SyncCompleter.complete (dart:async/future_impl.dart:51) E/flutter (25796): #9 _AsyncAwaitCompleter.complete. (dart:async-patch/async_patch.dart:33) E/flutter (25796): #10
_rootRun (dart:async/zone.dart:1120) E/flutter (25796): #11 _CustomZone.run (dart:async/zone.dart:1021) E/flutter (25796): #12 _CustomZone.runGuarded (dart:async/zone.dart:923) E/flutter (25796): #13 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963) E/flutter (25796): #14 _rootRun (dart:async/zone.dart:1124) E/flutter (25796): #15 _CustomZone.run (dart:async/zone.dart:1021) E/flutter (25796): #16
_CustomZone.runGuarded (dart:async/zone.dart:923) E/flutter (25796): #17 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963) E/flutter (25796): #18 _microtaskLoop (dart:async/schedule_microtask.dart:41) E/flutter (25796): #19
_startMicrotaskLoop (dart:async/schedule_microtask.dart:50)