取消图像选择器时,Flutter调试器崩溃

时间:2018-12-23 14:04:46

标签: dart flutter

当我取消图库选择器时,我的抖动调试器突然因此类日志而崩溃。无法继续调试。 enter image description here

是否可以跳过此步骤?还是只是暂时的错误?

Unhandled exception:
NoSuchMethodError: The getter 'className' was called on null.
Receiver: null
Tried calling: className
#0      Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
#1      serializeProcedure (package:front_end/src/fasta/kernel/utils.dart:99:29)
#2      FrontendCompiler.compileExpression (package:vm/frontend_server.dart:482:16)
<asynchronous suspension>
#3      _FlutterFrontendCompiler.compileExpression (package:frontend_server/server.dart:62:22)
#4      listenAndCompile.<anonymous closure> (package:vm/frontend_server.dart:797:20)
<asynchronous suspension>
#5      _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#7      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#8      _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
#9      _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
#10     _StringAdapterSink.add (dart:convert/string_conversion.dart:268:11)
#11     _LineSplitterSink._addLines (dart:convert/line_splitter.dart:154:13)
#12     _LineSplitterSink.addSlice (dart:convert/line_splitter.dart:129:5)
#13     StringConversionSinkMixin.add (dart:convert/string_conversion.dart:189:5)
#14     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
#15     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#16     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#17     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#18     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
#19     _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
#20     _StringAdapterSink.add (dart:convert/string_conversion.dart:268:11)
#21     _StringAdapterSink.addSlice (dart:convert/string_conversion.dart:273:7)
#22     _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:348:20)
#23     _Utf8ConversionSink.add (dart:convert/string_conversion.dart:341:5)
#24     _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:86:18)
#25     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
#26     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#27     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#28     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#29     _SyncStreamController._sendData (dart:async/stream_controller.dart:763:19)
#30     _StreamController._add (dart:async/stream_controller.dart:639:7)
#31     _StreamController.add (dart:async/stream_controller.dart:585:5)
#32     _Socket._onData (dart:io/runtime/binsocket_patch.dart:1721:41)
#33     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#34     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#35     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#36     _SyncStreamController._sendData (dart:async/stream_controller.dart:763:19)
#37     _StreamController._add (dart:async/stream_controller.dart:639:7)
#38     _StreamController.add (dart:async/stream_controller.dart:585:5)
#39     new _RawSocket.<anonymous closure> (dart:io/runtime/binsocket_patch.dart:1283:33)
#40     _NativeSocket.issueReadEvent.issue (dart:io/runtime/binsocket_patch.dart:826:14)
#41     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#42     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#43     _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#44     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)
Unhandled exception:
SocketException: Write failed (OS Error: Broken pipe, errno = 32), port = 0
#0      _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:1112:29)
#1      _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#2      _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#3      _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#4      _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)

这是我使用的代码

var image = await ImagePicker.pickImage(source: ImageSource.gallery);

1 个答案:

答案 0 :(得分:0)

您要取消选择器,以便它按预期返回null。你应该处理它。

您还有file_picker插件,其中包括图像选择器,并且还可以根据需要选择其他文件格式。