Search code examples
androidflutterdartnetworkimageviewimage-file

In Flutter - How to pass the image downloaded from the url


Through the API I retrieve data of an object - including its url. I show on one screen an image with url (Image.Network()). Now, after clicking on this image on the list, I want to move to a single image view - how do I pass the image, not the url, to a new view so that the application doesn't have to download it from the url again?


Solution

  • you can pass the image to Other Class like this

    Navigator.push(
              context, MaterialPageRoute(builder: (context) => OtherClass(data: image)));
    

    and in Other class receive the image like

       var data;
    
       OtherClass({Key key, @required this.data}) : super(key: key);