errorBuilder property

ImageErrorWidgetBuilder? errorBuilder
final

A builder function that is called if an error occurs during 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.

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,
    ),
    child: Lottie.network(
      'https://example.does.not.exist/lottie.json',
      errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
        // Appropriate logging or analytics, e.g.
        // myAnalytics.recordError(
        //   'An error occurred loading "https://example.does.not.exist/animation.json"',
        //   exception,
        //   stackTrace,
        // );
        return const Text('😢');
      },
    ),
  );
}

Implementation

final ImageErrorWidgetBuilder? errorBuilder;