The getter 'instance' isn't defined for the type 'Firestore'

前端 未结 2 1540
陌清茗
陌清茗 2020-11-29 13:12

Hi guys when i\'m trying to declare a instance of Firestore he give this error ! all that\'s happening after i upgrade my Flutter to last version

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-29 13:46

    Starting from cloud_firestore version 0.14.0:

    In the newest version of cloud_firestore, the class Firestore was deprecated now you have to use FirebaseFirestore, so just do:

    Import the package:

    import 'package:cloud_firestore/cloud_firestore.dart'
    

    To create an instance:

    final databaseReference  = FirebaseFirestore.instance;
    

    Other Links Regarding The Changes on Firebase:

    No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp() in Flutter and Firebase

    Undefined class 'FirebaseUser'

    cloud_firestore 0.14.0 how to use the data method

提交回复
热议问题