我创建了带图像和动画的简单扑动应用程序,
当我使用'flutter run'命令
调试和运行应用程序时,它运行得非常顺利但是当我尝试热重新加载时,它会超出错误列表,并且我总是需要重新调整flutter应用并再次运行它。
Initializing hot reload...
Syncing files to device Redmi Note 4...
TimeoutException: Request to Dart VM Service timed out:
ext.flutter.evict({value
: AssetManifest.json, isolateId: isolates/428680573})
#0 VM.invokeRpcRaw (package:flutter_tools/src/vmservice.dart:741)
<asynchronous suspension>
#1 Isolate.invokeRpcRaw
(package:flutter_tools/src/vmservice.dart:998)
#2 Isolate.invokeFlutterExtensionRpcRaw
(package:flutter_tools/src/vmservic
e.dart:1127)
<asynchronous suspension>
#3 Isolate.flutterEvictAsset
(package:flutter_tools/src/vmservice.dart:1204
)
<asynchronous suspension>
#4 HotRunner._evictDirtyAssets
(package:flutter_tools/src/run_hot.dart:302)
<asynchronous suspension>
#5 HotRunner._reloadSources
(package:flutter_tools/src/run_hot.dart:615)
<asynchronous suspension>
#6 HotRunner.restart (package:flutter_tools/src/run_hot.dart:457)
<asynchronous suspension>
#7 HotRunner.handleTerminalCommand
(package:flutter_tools/src/run_hot.dart:
236)
<asynchronous suspension>
#8 ResidentRunner.processTerminalInput
(package:flutter_tools/src/resident_
runner.dart:740)
<asynchronous suspension>
#9 _rootRunUnary (dart:async/zone.dart:1134)
#10 _CustomZone.runUnary (dart:async/zone.dart:1031)
#11 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933)
#12 _BufferingStreamSubscription._sendData
(dart:async/stream_impl.dart:330)
#13 _BufferingStreamSubscription._add
(dart:async/stream_impl.dart:257)
#14 _SyncBroadcastStreamController._sendData
(dart:async/broadcast_stream_co
ntroller.dart:379)
#15 _BroadcastStreamController.add
(dart:async/broadcast_stream_controller.d
art:254)
#16 _AsBroadcastStreamController.add
(dart:async/broadcast_stream_controller
.dart:480)
#17 _rootRunUnary (dart:async/zone.dart:1134)
#18 _CustomZone.runUnary (dart:async/zone.dart:1031)
#19 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933)
#20 _BufferingStreamSubscription._sendData
(dart:async/stream_impl.dart:330)
#21 _BufferingStreamSubscription._add
(dart:async/stream_impl.dart:257)
#22 _SinkTransformerStreamSubscription._add
(dart:async/stream_transformers.
dart:68)
#23 _EventSinkWrapper.add (dart:async/stream_transformers.dart:15)
#24 _StringAdapterSink.add (dart:convert/string_conversion.dart:268)
#25 _SimpleAsciiDecoderSink.add (dart:convert/ascii.dart:298)
#26 _ConverterStreamEventSink.add
(dart:convert/chunked_conversion.dart:86)
#27 _SinkTransformerStreamSubscription._handleData
(dart:async/stream_transf
ormers.dart:120)
#28 _rootRunUnary (dart:async/zone.dart:1134)
#29 _CustomZone.runUnary (dart:async/zone.dart:1031)
#30 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933)
#31 _BufferingStreamSubscription._sendData
(dart:async/stream_impl.dart:330)
#32 _BufferingStreamSubscription._add
(dart:async/stream_impl.dart:257)
#33 _StreamController&&_SyncStreamControllerDispatch._sendData
(dart:async/s
tream_controller.dart:763)
#34 _StreamController._add (dart:async/stream_controller.dart:639)
#35 _StreamController.add (dart:async/stream_controller.dart:585)
#36 _Socket._onData (dart:io-patch/socket_patch.dart:1654)
#37 _rootRunUnary (dart:async/zone.dart:1138)
#38 _CustomZone.runUnary (dart:async/zone.dart:1031)
#39 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933)
#40 _BufferingStreamSubscription._sendData
(dart:async/stream_impl.dart:330)
#41 _BufferingStreamSubscription._add
(dart:async/stream_impl.dart:257)
#42 _StreamController&&_SyncStreamControllerDispatch._sendData
(dart:async/s
tream_controller.dart:763)
#43 _StreamController._add (dart:async/stream_controller.dart:639)
#44 _StreamController.add (dart:async/stream_controller.dart:585)
#45 new _RawSocket.<anonymous closure> (dart:io-
patch/socket_patch.dart:1231
)
#46 _NativeSocket.issueReadEvent.issue (dart:io-
patch/socket_patch.dart:784)
#47 _microtaskLoop (dart:async/schedule_microtask.dart:41)
#48 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
#49 _runPendingImmediateCallback (dart:isolate-
patch/dart:isolate/isolate_pa
tch.dart:113)
#50 _RawReceivePortImpl._handleMessage (dart:isolate-
patch/dart:isolate/isol
ate_patch.dart:166)
Application finished.
此错误未显示有关发生位置的详细信息。
如果加载图片资源有问题, 我在根文件夹的images目录中添加了图片, 并在pubspec.yaml文件中给出了资产链接
当我运行应用程序但是应用程序拒绝热重启或热重新加载时,图像现在显示良好。
我尝试重新安装Flutter SDK并尝试过其他项目示例, 热重载在其他项目中运行良好。
答案 0 :(得分:1)
好的,我发现了这个问题, 这是我用于启动画面的计时器类的问题,
我没有将async
与使用Duration
和Timer
类的调用方法一起使用,它在主线程上运行,
没有async
它运行良好,但它也因热重载而产生问题,因为它没有在后台运行。