无法显示网络图像

问题描述

我正在尝试使用网络图像显示图像,但出现以下错误

my_domain_name%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B.blob.core.windows.net

不是有效的本地链接地址,但包含%。范围ID应为 用作链接本地地址的一部分。 (在第23个字符处) easyentrysystemstorage%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B.blob.co ...

我尝试使用以下代码对其进行解码,但仍然出现错误

var encoded = Uri.encodeFull(userProfile.imagePath);
  var decoded = Uri.decodeFull(encoded);
  return Container(
    alignment: Alignment.center,child: Container(
      width: 140.0,height: 140.0,decoration: Boxdecoration(
          borderRadius: BorderRadius.circular(30.0),image: decorationImage(
              image: NetworkImage(
                decoded,),fit: BoxFit.cover)
      ),);

尽管在浏览器中可以使用相同的URL,但即使在编码和解码后也无法使用。

解决方法

您应仅使用解码:

var decoded = Uri.decodeFull(userProfile.imagePath);

来自:

my_domain_name%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B.blob.core.windows.net

收件人:

my_domain_name​​​​​.blob.core.windows.net