0

I write a DESKTOP flutter app using cloud-stored firebase and I model my firebase data class. I don't understand that when I run on Android or Web platform, it's normal. But when running on desktop platform, it has error and I'm not able to get data from firebase. Please help me!

This is my model:

class ResidentData {
  String? id;
  String? name;
  String? type;
  String? number;
  String? timeIn;

  ResidentData({this.id, this.name, this.type, this.number, this.timeIn});

  ResidentData.fromDocumentSnapshot(DocumentSnapshot<Map<String, dynamic>> doc)
      : id = doc.id,
        name = doc.data()!["name"],
        type = doc.data()!["type"],
        number = doc.data()!["number"],
        timeIn = doc.data()!["time_in"];

}

This is my future method to get data from Firebase to a Resident List model:

Future <List<ResidentData>> getListResidentData() async {
  var snapshot = await FirebaseFirestore.instance.collection('user_data').get();
  return snapshot.docs.map((e) => ResidentData.fromDocumentSnapshot(e)).toList();
}

The error is: MissingPluginException(No implementation found for method Query#get on channel plugins.flutter.io/firebase_firestore)

I try to get data by using fromJson func in my model:

ResidentData.fromJson(Map<String, dynamic> json) {
  id = json['id'];
  name = json['name'];
  type = json['type'];
  number = json['number'];
  timeIn = json['time_in'];
}

Because I build my app with future builder, so I get data from firebase (as stream) and I change to future like this:

 Stream<List<ResidentData>> readResidentData() {
  var readAccount = FirebaseFirestore.instance
      .collection('user_data')
      .snapshots().map((snapshot) => snapshot.docs.map((doc) => ResidentData.fromJson(doc.data())).toList());
  return readAccount;
}
Future<List<ResidentData>> getListResident() async{
  var listResident = await readResidentData().first;
  return listResident;
}

I see that when running on desktop platform, it also has error.

  • What type of desktop machine are you trying to run this on? – Frank van Puffelen Nov 01 '22 at 13:43
  • just my pc (win 10) bro – The Hung Bui Nov 01 '22 at 14:22
  • The Firebase SDKs for Flutter do not support Windows platforms at the moment. See https://firebase.google.com/docs/flutter/setup?platform=android#available-plugins for a list of supported platforms. For another plugin that does work on all platforms, have a look at https://stackoverflow.com/questions/69221292/how-to-integrate-flutter-windows-app-with-firebase – Frank van Puffelen Nov 01 '22 at 14:29

0 Answers0