1

I want to decode a gif with the image package using DecodeGifAnimation, but it takes too long and causes my webapp to freeze. The library also doesn't seem to have any async methods. I looked up how to do asynchronous processing in Dart, and it seems that I need to use Futures, although I'm not sure how to create one for my function.

Not really sure what I'm doing

void decode(Uint8List data) {
  Future anim = decodeGifAnimation(data); // but it returns Animation, not a Future!
  anim.then(prepare);
}

1 Answer 1

7
void decode(Uint8List data) {
  new Future(() => decodeGifAnimation(data)).then(prepeare);
}

or

Future decode(Uint8List data) {
  return new Future(() => decodeGifAnimation(data)).then(prepeare);
}

if you want to do some async processing when the method returns to call the method like

decode(data).then(xxx);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.