简体   繁体   中英

(FLUTTER) Getting error while trying to display a network image whose URL I am getting as an argument from the previous screen

My first screen is using the same image and I am not facing any issue there but when I go to the second screen and wanna use the same image, I am getting "Invalid argument(s): No host specified in URI file:///Instance%20of%20'Future%3Cdynamic%3E'". I tried Urifullencode and made sure that the URL of the image has https:// in it but it is still not working for some reason

here is the code:

getImageUrl() async {
    var image = await Get.arguments['imageUrl'];
    if (image == null){
      return 'https://miro.medium.com/max/880/0*H3jZONKqRuAAeHnG.jpg';
    }
    else{
      return image;
    }
  }

following is the widget in which I am using the above function

 ClipRRect(
                borderRadius: BorderRadius.circular(10),
                child: Image.network(
                Uri.encodeFull(getImageUrl().toString()),
                  ),
              ),

And lastly the error:

════════ Exception caught by image resource service ════════════════════════════

The following ArgumentError was thrown resolving an image codec: Invalid argument(s): No host specified in URI file:///Instance%20of%20'Future%3Cdynamic%3E'

I still get the same error even if I remove async-await, and in my emulator as soon as I navigate to the second screen, everything works well except the container that is holding the network image (it displays a crossed-out image of the same error message).

ah sorry, silly mistake on my part. The screen from where I was getting the arguments had a spelling mistake in one of the argument variables. Fixed it, its working now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM