I have some data in the form of objects on my firebase rtdb, I just want to retrieve the data on my device and save it using the persistence method. I've been on this for a month now and looked out for a lot of possible solutions but that doesn't seem to help. Here is the structure of my data:
(Let me know if you require any missing piece of information)
Thanks in advance!
Edit #1
This is what I tried
class contact{
final String name,desig,category,ip_direct,ip_office,ip_res,ll_off,ll_res,mob;
contact({this.name,this.desig,this.category,
this.ip_direct,this.ip_office,this.ip_res,this.ll_off,this.ll_res,this.mob});
factory contact.fromJson(Map<dynamic, dynamic> json){
return contact(
name: json["Name"],
desig: json["Design"],
category: json["Category"],
ip_direct: json["IP Direct"].toString(),
ip_office: json["IP Office"].toString(),
ip_res: json["IP Home"].toString(),
ll_off: json["LL Office"].toString(),
ll_res: json["LL Home"].toString(),
mob: json["Mobile"].toString(),
);
}
}
Future<List<contact>> getList()async{
final dbRef = FirebaseDatabase.instance.reference().child("Deans");
List<contact> list=new List();
DataSnapshot snap=await dbRef.once();
List<dynamic> obj=snap.value;
for(int i=0; i<obj.length; i++){
list.add(contact.fromJson(obj[i]));
}
return list;
}
I cannot persist data here