Skip to content

Image.network handle bad url image, like 404 #34451

Description

@cosinus84

The code below still shows as an exception. This is a very common situation.

 Image.network("${image}x",
                    fit: BoxFit.cover,
                    width: 150,
                    height: 150, loadingBuilder: (BuildContext context,
                        Widget child, ImageChunkEvent loadingProgress) {
                  if (loadingProgress == null) {
                    return child;
                  }
                  return Platform.isIOS
                      ? CupertinoActivityIndicator(radius: 20)
                      : CircularProgressIndicator();
                });
              } catch(_) {
                return Container();
              }

[✓] Flutter (Channel dev, v1.7.3, on Mac OS X 10.14.5 18F132, locale en-RO)
• Flutter version 1.7.3 at /Users/devx/flutter
• Framework revision 362b999 (6 days ago), 2019-06-07 12:43:27 -0700
• Engine revision 0602dbb
• Dart version 2.3.2 (build 2.3.2-dev.0.1 6e0d978505)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions