fluttercandies / extended_image

A powerful official extension library of image, which support placeholder(loading)/ failed state, cache network, zoom pan image, photo view, slide out page, editor(crop,rotate,flip), paint custom etc.
https://fluttercandies.github.io/extended_image/
MIT License
1.94k stars 505 forks source link

ExtendedImage.asset不能展示代码中的图片 #654

Closed wangzhipeng-vicky closed 1 month ago

wangzhipeng-vicky commented 10 months ago

Platforms

Android

Description

我使用 ExtendedImage.asset展示项目或者flutter_gallery_assets中的图片都不能显示

但是我使用Image.asset(url, fit: BoxFit.cover, package: 'flutter_gallery_assets')都能正常显示的

这是什么原因呢 或者给个demo啥的

My code

No response

Try do it

No response

zmtzawqlp commented 10 months ago

最好是有一个能运行的最简单的能重现问题的demo

wangzhipeng-vicky commented 10 months ago

最好是有一个能运行的最简单的能重现问题的demo

`ExtendedImage.asset( 'assets/images/ali_connors.png', width: 20,

  height: 20,

  fit: BoxFit.cover,

  border: Border.all(color: Colors.blue, width: 1.0),
  enableLoadState: true,
  //图片很大,需要长时间加载   设置为了 true,这样也会有状态回调了,(默认只有网络图片,enableLoadState 为 true)
  shape: boxShape,
  // package: "flutter_gallery_assets",//他不起效  所以我就在外边把全路径拼好
  borderRadius: BorderRadius.all(Radius.circular(borderRadius)),
  //cancelToken: cancellationToken,
  loadStateChanged: (ExtendedImageState state) {
    debugPrint(state.lastException.toString());
    switch (state.extendedImageLoadState) {
      case LoadState.loading: //加载中。。。
        if(controller!=null){
          controller.reset();

        }
        return Image.asset(
          "assets/loading.gif",
          fit: BoxFit.fill,
        );
        break;

    ///if you don't want override completed widget
    ///please return null or state.completedWidget
    //return null;
    //return state.completedWidget;
      case LoadState.completed: //加载完成
        if(controller!=null){
          controller.forward();

        }
        return FadeTransition(
          opacity:
          CurvedAnimation(parent: controller!, curve: Curves.easeIn),
          child: ExtendedRawImage(
            //如果你想重写完成图片的 size 或者 sourceRect, 你可以通过使用 ExtendedRawImage 来完成
            image: state.extendedImageInfo?.image,
          ),
        );
        break;
      case LoadState.failed: //加载失败
        if(controller!=null){
          controller.reset();

        }
        return GestureDetector(
          child: Stack(
            fit: StackFit.expand,
            children: <Widget>[
              Image.asset(
                "assets/failed.jpg",
                fit: BoxFit.fill,
              ),
              const Positioned(
                bottom: 0.0,
                left: 0.0,
                right: 0.0,
                child: Text(
                  "load image failed, click to reload",
                  textAlign: TextAlign.center,
                ),
              )
            ],
          ),
          onTap: () {
            state.reLoadImage();
          },
        );
        break;
    }
  },
)`
wangzhipeng-vicky commented 10 months ago

最好是有一个能运行的最简单的能重现问题的demo

报这个错 image

zmtzawqlp commented 10 months ago

runnable,simple demo

zmtzawqlp commented 1 month ago

please provider runnable simple demo