StateError: Bad state: Cannot clone a disposed image. The clone() method of a previously-disposed Image was called. Once an Image object has been disposed, it can no longer be used to create handles, as the underlying data may have been released.
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 領域
- mobile-dev
調査の方向性
まず、BlurHashをネットワーク画像のプレースホルダーとして使用して報告されたランタイムエラーを再現し、次にパッケージのBlurHash画像処理パスとライフサイクルを調査します。Image.networkの直接的な動作と比較します。ネットワーク画像のプレースホルダーが破棄済みの画像をクローンしようとしなくなり、既存の画像読み込みおよびエラー時の動作が維持されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
After adding flutter_blurhash to my project, I started seeing the following runtime error:
StateError: Bad state: Cannot clone a disposed image.
The clone() method of a previously-disposed Image was called. Once an Image object has been disposed, it can no longer be used to create handles, as the underlying data may have been released.
When using BlurHash with a network image, Flutter sometimes throws StateError: Bad state: Cannot clone a disposed image.
code example:
/// {@template image_loader}
/// ImageLoader widget.
/// {@endtemplate}
class ImageLoader extends StatefulWidget {
/// {@macro image_loader}
const ImageLoader({
required this.imgUrl,
this.blurHash,
this.isCupertinoStyle = true,
this.fit = BoxFit.cover,
this.onErrorWidget,
this.borderRadius,
this.backgroundColor,
this.height,
this.width,
this.blendMode,
this.color,
super.key,
});
final String? imgUrl;
final String? blurHash;
final bool isCupertinoStyle;
final BoxFit? fit;
final Widget? onErrorWidget;
final BorderRadius? borderRadius;
final Color? backgroundColor;
final double? height;
final double? width;
final BlendMode? blendMode;
final Color? color;
@override
State<ImageLoader> createState() => _ImageLoaderState();
}
class _ImageLoaderState extends State<ImageLoader> {
final int animationDuration = 800;
@override
Widget build(BuildContext context) => widget.imgUrl != null && widget.imgUrl!.isNotEmpty
? ColoredBox(
color: widget.backgroundColor ?? Colors.transparent,
child: ClipRRect(
borderRadius: widget.borderRadius ?? BorderRadius.circular(0),
child: widget.blurHash != null &&
widget.blurHash!.isNotEmpty &&
!widget.imgUrl!.contains('.png')
? BlurHash(
hash: widget.blurHash!,
decodingHeight: widget.height?.round() ?? 32,
decodingWidth: widget.width?.round() ?? 32,
color: Colors.white,
image: widget.imgUrl,
imageFit: widget.fit ?? BoxFit.cover,
curve: Curves.easeInOut,
duration: Duration(milliseconds: animationDuration),
)
: Image.network(
widget.imgUrl!,
fit: widget.fit,
height: widget.height,
width: widget.width,
color: widget.color,
colorBlendMode: widget.blendMode,
cacheHeight: widget.height?.round(),
cacheWidth: widget.width?.round(),
errorBuilder: (context, error, stackTrace) => widget.onErrorWidget ??
const Icon(Icons.hide_image_rounded),
),
),
)
: Image.asset('assets/placeholder.png', fit: widget.fit);
}
This error does not appear when using Image.network directly.
It only happens when BlurHash is used as a placeholder together with a network image.
- 主要言語
- Dart
- スター
- 576
- フォーク
- 80
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
fluttercommunity/flutter_blurhash のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 30/100
fluttercommunity/flutter_blurhash#66 · コメント 1 件 ·
-
CacheManagerオープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
fluttercommunity/flutter_blurhash#61 · リアクション 4 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
fluttercommunity/flutter_blurhash#51 · コメント 1 件 · リアクション 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 25/100
fluttercommunity/flutter_blurhash#50 · コメント 4 件 · リアクション 3 件 ·
fluttercommunity/flutter_blurhash の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
OscillateLabsLLC/ovos-gui-visage#52 ·
メンテナーはふだん 1 日以内に返信
-
bug triage
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
fluttercommunity/plus_plugins#4018 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
VeryGoodOpenSource/vgv_ai_cli#150 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
PATILYASHH/XPENC#206 · コメント 1 件 ·