Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

先改变数字 如果提交错误 返回原来数字 为什么报错? #85

Closed
simanlx opened this issue Jun 19, 2024 · 1 comment
Closed

Comments

@simanlx
Copy link

simanlx commented Jun 19, 2024

Platforms

dart

Description

var aaaa= false;
Future likeMomentsOne(workMomentID,index) {
///send your request here

aaaa=!aaaa;
final Completer<bool> completer = new Completer<bool>();
completer.complete(aaaa);
aaaa=!aaaa;
await Timer(const Duration(milliseconds: 500), () {
  print("dddll");
  // if your request is failed,return null,
  completer.complete(aaaa);

});



return completer.future;

}

My code

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: Future already completed
#0 _AsyncCompleter.complete (dart:async/future_impl.dart:41:31)[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: Future already completed
#0 _AsyncCompleter.complete (dart:async/future_impl.dart:41:31)

Try do it

No response

@zmtzawqlp
Copy link
Member

zmtzawqlp commented Jun 19, 2024

Future already completed

Completer 不是stream,不能多次调用complete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants