type 'FirebaseFirestore' is not a subtype of type 'Firestore'

Viewed 889

I have added firebase_core: ^0.5.0, cloud_firestore: ^0.14.0+2 as dependencies and in main added

void main()async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(MaterialApp(
    debugShowCheckedModeBanner: false,
    home: Home(),
  ));
}

In my service class I have

class SupplierService {
  Firestore db = Firestore.instance;

  // retrieve data
  Future<List<DocumentSnapshot>> getSuppliers() {
    return db.collection("suppliers").getDocuments().then((snaps) {
        return snaps.documents;
    });
  }
}

where I retrieve some data in suppliers collection. But I navigate to corresponding page wich has implemented it throws me

type 'FirebaseFirestore' is not a subtype of type 'Firestore'

What was the problem and how can I solve this

1 Answers

You're using a now-deprecated API. Firestore is no longer supposed to be used. Your code should read like this instead:

FirebaseFirestore db = FirebaseFirestore.instance;
Related