Undefined name 'Firestore' Flutter

Viewed 11585
dependencies:
  flutter:
    sdk: flutter
    


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  cloud_firestore:

I config it properly please help

4 Answers

There is no class named Firestore. Use FirebaseFirestore.instance instead.

example:

var snapshot = FirebaseFirestore.instance
          .collection('chat')
          .orderBy('createdAt', descending: true)
          .snapshots();

Change the name from 'Firestore' to 'FirebaseFirestore'.

Example

Install Dependencies :-

dependencies:
  flutter:
    sdk: flutter


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.0
  firebase_auth:
  cloud_firestore: ^0.14.3
  firebase_core: ^0.5.2

Import Package :-

import 'package:cloud_firestore/cloud_firestore.dart';

Access Firestore :-

Future getMembers() async {
    var firestore = FirebaseFirestore.instance;
    QuerySnapshot querySnapshot = await firestore.collection("Members").get();
    final documents = querySnapshot.docs;
    return documents
}

use this pubspec.yaml

cloud_firestore: ^0.13.5

Related