networkWithFallback static method

Image networkWithFallback(
  1. String src, {
  2. Key? key,
  3. double? width,
  4. double? height,
  5. Color? color,
  6. BoxFit? fit,
  7. String? fallback,
})

Creates a network image with error handling

Implementation

static Image networkWithFallback(
  String src, {
  Key? key,
  double? width,
  double? height,
  Color? color,
  BoxFit? fit,
  String? fallback,
}) {
  return Image.network(
    src,
    key: key,
    width: width,
    height: height,
    color: color,
    fit: fit,
    errorBuilder: (context, error, stackTrace) {
      return fallback != null
          ? Image.asset(fallback, width: width, height: height, fit: fit)
          : const Icon(Icons.error);
    },
  );
}