fluttercandies / like_button

Like Button is a flutter library that allows you to create a button with animation effects similar to Twitter's heart when you like something and animation effects to increase like count.
MIT License
469 stars 96 forks source link

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

Closed simanlx closed 4 months ago

simanlx commented 4 months ago

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 commented 4 months ago

Future already completed

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