imageErrorBuilder not invoking when image URLs are broken

Viewed 33

I'm using the FadeInImage widget to load network images along with imageErrorBuilder. But, in some cases, imageErrorBuilder isn't working. Below is my source code.

FadeInImage(
            placeholder: const AssetImage('assets/placeholder.png'),
            imageErrorBuilder: (context, error, stackTrace) {
              return Image.asset('assets/placeholder.png',
                  fit: BoxFit.fitWidth);
            },
            image: NetworkImage(url!),
          )

I'm getting exceptions as given below.

======== Exception caught by image resource service ================================================
The following _Exception was thrown resolving an image codec:
Exception: NetworkImage is an empty file: https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/95KN8q3qubEVjPf9trgyur2nHx8T5RCmztRbLuQ5E5i/logo.png

======== Exception caught by image resource service ================================================
The following HttpException was thrown resolving an image codec:
Connection closed while receiving data, uri = https://raw.githubusercontent.com/solana-labs/token-list/b0e47e39f84cffb655f406eb569c57a88b5211cc/assets/mainnet/FnKE9n6aGjQoNWRBZXy4RW6LZVao7qwBonUbiD7edUmZ/logo.png

Does anyone suggest to me how to handle these types of cases?

Thanks in Advance.

0 Answers
Related