How do you load array and object from Cloud Firestore in Flutter

后端 未结 4 597
梦谈多话
梦谈多话 2020-12-01 02:52

I have a class that has several embedded arrays as well as a couple of objects. I\'m using Flutter and can\'t figure out how to read/write to Cloud Firestore.

I can r

4条回答
  •  感动是毒
    2020-12-01 03:38

    Firebase packages returns List types for Array/List types present in a snapshot. Try converting List to List or List before assigning to variables. And for GameReview object, currently, you are trying to assign object of Map to the object, it would be beneficial if you write static fromMap method in GameReview class which takes map argument and converts it to desired object structure, as you would see in many of flutters example codes.

    class GameReivew{
    
      static GameReivew fromMap(Map map){
        GameReivew gameReivew = new GameReivew();
        gameReivew.name = map["name"];
        gameReivew.howPopular = map["howPopular"];
        ....
    
        return gameReivew;
      }
    }
    

提交回复
热议问题