2014-04-29 3 views
1

DecodeGifAnimation을 사용하여 the image package으로 GIF를 디코딩하려고하지만 너무 길어서 webapp이 멈 춥니 다. 라이브러리에는 비동기 메소드도없는 것 같습니다. Dart에서 비동기 처리를 수행하는 방법을 살펴 보았고, Futures를 사용해야한다고 생각합니다. 그러나 함수를 작성하는 방법을 잘 모르겠습니다. 당신이 방법은 메서드를 호출 반환 할 때 약간의 비동기 처리를 수행하려는 경우 내가Dart에서 비동기 적으로 비동기 함수를 호출 할 수 있습니까?

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

답변

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

또는

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

을 뭘하는지

정말 확실하지 않음 like

decode(data).then(xxx); 
관련 문제