getImageProvider function

ImageProvider<Object>? getImageProvider(
  1. XFile? image,
  2. String? imageUrl, {
  3. double scale = 1.0,
})

Implementation

ImageProvider<Object>? getImageProvider(XFile? image, String? imageUrl,
    {double scale = 1.0}) {
  if (image != null) {
    if (kIsWeb) {
      return CachedNetworkImageProvider(image.path, scale: scale);
    }

    return FileImage(
      File(image.path),
      scale: scale,
    );
  } else if (imageUrl != null) {
    if (defaultTargetPlatform == TargetPlatform.android ||
        defaultTargetPlatform == TargetPlatform.iOS ||
        defaultTargetPlatform == TargetPlatform.macOS ||
        kIsWeb) {
      return CachedNetworkImageProvider(imageUrl, scale: scale);
    } else {
      return NetworkImage(imageUrl, scale: scale);
    }
  } else {
    return null;
  }
}