Search code examples
flutterdartflutter-imagearabic-support

Flutter Image from Arabic URL


I try:

Image.network("http://ar.latifaonline.com/wp-content/uploads/2022/08/ألبوم-لطيفة-2022.png"),

but that does not work because Arabic characters convert to become :

"http://ar.latifaonline.com/wp-content/uploads/2022/08/%D8%A3%D9%84%D8%A8%D9%88%D9%85-%D9%84%D8%B7%D9%8A%D9%81%D8%A9-2022.png"

and that does not give any image but returns this error:

Exception has occurred. HttpException (HttpException: Connection closed before full header was received, uri = http://ar.latifaonline.com/wp-content/uploads/2022/08/%D8%A3%D9%84%D8%A8%D9%88%D9%85-%D9%84%D8%B7%D9%8A%D9%81%D8%A9-2022.png)


Solution

  • The reason you get this error is not because of the Arabic characters, is because of http, change it to https and it will work.

    if you don't have access to your backend code try this:

    String yourUrl =
            "http://ar.latifaonline.com/wp-content/uploads/2022/08/ألبوم-لطيفة-2022.png";
    
    yourUrl = yourUrl.replaceFirst('http://', "https://");
    
    Image.network(yourUrl)