'Unable to Load image from url in flutter

I am Fetching images from URL and it is providing broken images while on the web the same URL is providing complete and accurate images.

Scheme not starting with alphabetic character

throwing error.

// Depending on where the exception was thrown, the image cache may not
  // have had a chance to track the key in the cache at all.
  // Schedule a microtask to give the cache a chance to add the key.

Image Url:- https://smott.world/upload/source/1646761765-WhatsApp Image 2022-03-08 at 5.41.29 PM.jpeg



Solution 1:[1]

This is happening because your url is not encoded, you can encode using Uri.encodeFull to encode. Encode url will replace white spaces by %20

Example:

var uri = Uri.encodeFull('https://smott.world/upload/source/1646761765-WhatsApp Image 2022-03-08 at 5.41.29 PM.jpeg');
var url = uri.toString();

// url will be "https://smott.world/upload/source/1646761765-WhatsApp%20Image%202022-03-08%20at%205.41.29%20PM.jpeg"

You can see more about percent encoding here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Guilherme Gabanelli