folksable / blurhash_ffi

a port of blurhash to flutter written in c via dart:ffi
https://pub.dev/packages/blurhash_ffi
BSD 3-Clause "New" or "Revised" License
41 stars 6 forks source link

Bad state: Future already completed when using CachedNetworkImageProvider #11

Closed mark8044 closed 11 months ago

mark8044 commented 11 months ago

The package works wonderfully when using NetworkImage provider

final imageProvider = NetworkImage(imageUrl);
final String blurHash = await BlurhashFFI.encode(imageProvider);

However, when trying to use a CachedNetworkImageProvider:

final imageProvider = CachedNetworkImageProvider(imageUrl);
final String blurHash = await BlurhashFFI.encode(imageProvider);

Then we get the following error:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: Future already completed
#0      _AsyncCompleter.complete (dart:async/future_impl.dart:43:31)
#1      BlurhashFFI._getImageInfoFromImageProvider.<anonymous closure> (package:blurhash_ffi/blurhash.dart:195:17)
<asynchronous suspension>

Despite the error, a blur hash string is still returned....

dhikshithrm commented 11 months ago

Hey @mark8044, this is a known issue caused by cached_network_image package, please follow #6 for updates

mark8044 commented 11 months ago

@dhikshith12 Ah ok I see, I will follow there, thank you