errorBuilder property

(Widget Function(BuildContext, Object, StackTrace?)?) errorBuilder
final

A builder function that is called if an error occurs during image loading.

If this builder is not provided, any exceptions will be reported to FlutterError.onError. If it is provided, the caller should either handle the exception by providing a replacement widget, or rethrow the exception.

Important:

The following sample uses errorBuilder to show a '😢' in place of the image that fails to load, and prints the error to the console.

Widget build(BuildContext context) {
  return DecoratedBox(
    decoration: BoxDecoration(
      color: Colors.white,
      border: Border.all(),
      borderRadius: BorderRadius.circular(20),
    ),
    child: Image.network(
      'https://example.does.not.exist/image.jpg',
      errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
        // Appropriate logging or analytics, e.g.
        // myAnalytics.recordError(
        //   'An error occurred loading "https://example.does.not.exist/image.jpg"',
        //   exception,
        //   stackTrace,
        // );
        return const Text('😢');
      },
    ),
  );
}

From flutter documentation

Implementation

final Widget Function(BuildContext, Object, StackTrace?)? errorBuilder;