Closed simanlx closed 4 months ago
dart
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;
}
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: Future already completed
No response
Future already completed
Completer 不是stream,不能多次调用complete
Platforms
dart
Description
var aaaa= false; Future likeMomentsOne(workMomentID,index) {
///send your request here
}
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