小编Ben*_*nyi的帖子

Dart 使用 .listen().onError().onDone() 流错误

我有一些看起来像这样的代码的问题。在这个表格中我有一个错误

The expression here has a type of 'void', and therefore can't be used. Try checking to see if you're using the correct API; there might be a function or call that returns void you didn't expect. Also check type parameters and variables which might also be void.dart(use_of_void_result).

如果我删除 .onDone() 错误就会消失。为什么?请 ELI5 :-) 我正在查看https://api.dart.dev/stable/2.7.0/dart-async/Stream/listen.html但似乎仍然误解了一些东西。我还阅读了https://api.dart.dev/stable/2.7.0/dart-async/StreamSubscription/onDone.html

serviceName.UploadThing(uploadRequest).listen((response) {
  uploadMessageOutput = response.message;
  if (response.uploadResult) {
    showSuccess();
  } else {
    showError();
  }
  getUploadFileList(event);

  isSaveInProgress = false;
}).onError((error) {
  isSaveInProgress = …
Run Code Online (Sandbox Code Playgroud)

dart

3
推荐指数
1
解决办法
1068
查看次数

标签 统计

dart ×1