我想使用DecodeGifAnimation 解码带有图像包的gif ,但它需要太长时间并导致我的webapp冻结.该库似乎也没有任何异步方法.我查看了如何在Dart中进行异步处理,似乎我需要使用Futures,虽然我不知道如何为我的函数创建一个.
不太确定我在做什么
void decode(Uint8List data) {
Future anim = decodeGifAnimation(data); // but it returns Animation, not a Future!
anim.then(prepare);
}
Run Code Online (Sandbox Code Playgroud)
void decode(Uint8List data) {
new Future(() => decodeGifAnimation(data)).then(prepeare);
}
Run Code Online (Sandbox Code Playgroud)
要么
Future decode(Uint8List data) {
return new Future(() => decodeGifAnimation(data)).then(prepeare);
}
Run Code Online (Sandbox Code Playgroud)
如果你想在方法返回调用方法时做一些异步处理
decode(data).then(xxx);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
79 次 |
最近记录: |