The thing which you are doing wrong is this:
// You have initialised your List as a Offset Object Type
List<Offset> pointList;
Secondly, the data you are assigning is a String
, if you closely take a look at that firebase.
"Offset(x,y)"
Finally, trying to assign the String
value to a List
of type Offset class/object
If you want to make the thing works, then either make the List
of type String
and then add it to the List
List<String> pointlist = List.from(value.data['point']);
Or first Add the data to the Offset Object like this, and then pass it to the List
List<Offset> pointList = <Offset>[];
getdata() async{
await Firestore.instance.collection("points").document('biZV7cepFJA8T6FTcF08').get().then((value){
setState(() {
// first add the data to the Offset object
List.from(value.data['point']).forEach((element){
Offset data = new Offset(element);
//then add the data to the List<Offset>, now we have a type Offset
pointList.add(data);
});
});
});
}
SUMMARY
Always look for the data type you are giving to the List
, if you are trying to add the data which is not a type T
of List<T>
, you will always get this error of type mismatch. Hope this will give you some clarity and some basic idea about programming. Keep learning :)
value.data['point']
can't be converted to aList<Offset>
... can you show what isvalue.data['point']
? - Claudio Redi