mercredi 1 janvier 2020

Flutter web fetch json data and build list works locally, not working on deploy to Firebase

I am building a web app with flutter, but one of the functions that works on local server is not working when I deploy.
I am using json files hosted at 000webhost to store data that the app fetches and then displays. It works fine for the first fetch (both locally and hosted), but then when I choose an option from the created list - which should navigate to a new screen, fetch a new list, and display it - the new list is not displayed.
When run locally with IDE (IntelliJ CE), everything works fine: the initial list is fetched and displayed, and choosing an option from the list navigates to a new screen which displays the image from the initial list, and a list of new images from a new list. (Then an option can be selected, which navigates to a new screen, fetches another new list, and displays that as well - but the hosted site fails before getting this far.)
On the hosted site, the navigation works fine, the image that was fetched from the first http request is displayed at the top of the new screen as expected, but the new list does not appear.
Why would this work on local server, but not when hosted? And why will the first fetch action work, but not the second?
I am guessing that maybe the problem has something to do with some kind of network stuff that I don't understand, since the code seems to work fine on the local server. So, I don't really know what part of the code would be important to include, but I will include the parts that fetch the data.
I have looked for posts that may have already answered this question, but have not found a solution. I checked this post (Losing data while navigating screens in Flutter), but I do not think that it applies (unless I just don't understand, which is definitely a possibility).
Thank you for any help you can offer.

class StartPage {

  String collvar;
  String subcollvar;
  String cardtype;
  String label;
  String text1;
  String text2;
  String text3;
  String text4;
  String image1;
  String image2;
  String image3;
  String image4;
  String link1;
  String link2;
  String link3;
  String link4;
  String int1;
  String int2;
  String int3;
  String int4;

  StartPage(this.collvar, this.subcollvar, this.cardtype, this.label, this.text1, this.text2, this.text3, this.text4, this.image1, this.image2, this.image3, this.image4, this.link1, this.link2, this.link3, this.link4, this.int1, this.int2, this.int3, this.int4,);

  StartPage.fromJson(Map<String, dynamic> json) {

    collvar = json['collvar'];
    subcollvar = json['subcollvar'];
    cardtype = json['cardtype'];
    label = json['label'];
    text1 = json['text1'];
    text2 = json['text2'];
    text3 = json['text3'];
    text4 = json['text4'];
    image1 = json['image1'];
    image2 = json['image2'];
    image3 = json['image3'];
    image4 = json['image4'];
    link1 = json['link1'];
    link2 = json['link2'];
    link3 = json['link3'];
    link4 = json['link4'];
    int1 = json['int1'];
    int2 = json['int2'];
    int3 = json['int3'];
    int4 = json['int4'];
    /*print(label);*/

  }
}



Aucun commentaire:

Enregistrer un commentaire