Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] loadFailedChild doesn't show error widget #316

Closed
firebatu opened this issue Aug 16, 2020 · 2 comments
Closed

[BUG] loadFailedChild doesn't show error widget #316

firebatu opened this issue Aug 16, 2020 · 2 comments
Labels
bug Something isn't working P1
Projects

Comments

@firebatu
Copy link

firebatu commented Aug 16, 2020

I use NetworkImage provider to fetch image from the internet. Also I use the Container with placeholder as an argument for loadfailedchild, but in case of an error (Internet connection disabled) placeholder doesn't showing. I just see empty page. I noticed that this happens when using heroAttributes:
Code snippet:

class PhotoViewScreen extends StatelessWidget {
  static const routeName = '/photo-viewer';

  @override
  Widget build(BuildContext context) {
    final Map args = ModalRoute.of(context).settings.arguments as Map;
    return Theme(
      data: ThemeData.dark(),
      child: Scaffold(
        backgroundColor: Colors.black,
        appBar: AppBar(
          backgroundColor: Colors.black,
          actions: [
            IconButton(
              icon: const Icon(CommunityMaterialIcons.dots_vertical),
              onPressed: () {},
            ),
          ],
        ),
        body: Center(
          child: PhotoView(
              heroAttributes: PhotoViewHeroAttributes(tag: args['imageUrl']),
              filterQuality: FilterQuality.high,
              imageProvider: NetworkImage(args['imageUrl']),
              initialScale: PhotoViewComputedScale.contained * 0.9,
              minScale: PhotoViewComputedScale.contained * 0.8,
              maxScale: PhotoViewComputedScale.covered * 1.2,
              basePosition: Alignment.center,
              loadFailedChild: Container(
                height: 200,
                width: double.infinity,
                color: Colors.grey,
                child: const Icon(
                  Icons.error,
                  size: 70,
                  color: Colors.grey,
                ),
              ),
          ),
        ),
      ),
    );
  }
}
@firebatu firebatu added the bug Something isn't working label Aug 16, 2020
@firebatu firebatu changed the title loadfailedchild doesn't show error widget [BUG] loadFailedChild doesn't show error widget [BUG] Aug 16, 2020
@firebatu firebatu changed the title loadFailedChild doesn't show error widget [BUG] [BUG] loadFailedChild doesn't show error widget Aug 16, 2020
@renancaraujo renancaraujo added this to Todo in Bug solving via automation Aug 18, 2020
@renancaraujo renancaraujo moved this from Todo to In progress in Bug solving Aug 18, 2020
renancaraujo added a commit that referenced this issue Aug 22, 2020
This makes the image retrieval process not rely on a FutureBuilder.
Previously we recreated Image behavior by showing a loader whilst the image loads, using a completer to detect when the image had finished load.
Now we rely only on the good old state and some ifs in the build method.
Also, we have split that code from the custom child code. The main widget had logics for both image and custom child modes. Now we split that into two internal widgets, the wrappers.

This should resolve the following issues #316 #303
@renancaraujo
Copy link
Member

Should be fixed on #320

Bug solving automation moved this from In progress to Done Aug 22, 2020
@PerLycke
Copy link

PerLycke commented Aug 28, 2020

@renancaraujo For galleries, there is no errorBuilder option. There's a reason you didn't add errorBuilder for galleries?

const PhotoViewGallery.builder({
    Key key,
    @required this.itemCount,
    @required this.builder,
    this.loadingBuilder,
    this.loadFailedChild,
    this.backgroundDecoration,
    this.gaplessPlayback = false,
    this.reverse = false,
    this.pageController,
    this.onPageChanged,
    this.scaleStateChangedCallback,
    this.enableRotation = false,
    this.scrollPhysics,
    this.scrollDirection = Axis.horizontal,
    this.customSize,
  })  : pageOptions = null,
        assert(itemCount != null),
        assert(builder != null),
        super(key: key);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1
Projects
Bug solving
  
Done
Development

No branches or pull requests

3 participants