buildMediasfuImage function

Widget buildMediasfuImage(
  1. String source, {
  2. double? width,
  3. double? height,
  4. BoxFit? fit,
})

Returns an Image widget that handles both network URLs and local assets. Falls back to the bundled asset if the network image fails.

Implementation

Widget buildMediasfuImage(
  String source, {
  double? width,
  double? height,
  BoxFit? fit,
}) {
  if (source.startsWith('http')) {
    return Image.network(
      source,
      width: width,
      height: height,
      fit: fit,
      errorBuilder: (context, error, stackTrace) {
        return Image.asset(
          kDefaultMediaSFULogoAsset,
          width: width,
          height: height,
          fit: fit,
        );
      },
    );
  }
  return Image.asset(
    source,
    width: width,
    height: height,
    fit: fit,
  );
}