简体   繁体   English

扑动未定义的类'FirebaseFirestore'

[英]flutter undefined class 'FirebaseFirestore'

I am trying to get data from firebase firestore to the app I am building, it seems to be quite fine but I recieve this message on the console:我正在尝试将数据从 firebase firestore 获取到我正在构建的应用程序,这似乎很好,但我在控制台上收到了这条消息:

[Firestore]: The behavior for java.util.Date objects stored in Firestore is going to change AND YOUR APP MAY BREAK.
W/Firestore( 8224): To hide this warning and ensure your app does not break, you need to add the following code to your app before calling any other Cloud Firestore methods:
W/Firestore( 8224): 
W/Firestore( 8224): FirebaseFirestore firestore = FirebaseFirestore.getInstance();
W/Firestore( 8224): FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder()
W/Firestore( 8224):     .setTimestampsInSnapshotsEnabled(true)
W/Firestore( 8224):     .build();
W/Firestore( 8224): firestore.setFirestoreSettings(settings);

I am using the packages我正在使用包

 import 'package:flutter/material.dart';
 import 'auth.dart';
 import 'state_rut.dart';
 import 'package:cloud_firestore/cloud_firestore.dart';

and the code ttying to get the info goes:获取信息的代码如下:

final collection = Firestore.instance.collection('regions');
collection.orderBy('region_id').getDocuments()
    .then((data){
      print(data);
    })
    .catchError((e){
       print(e);
    });

I wanted to use at first the one in the page https://firebase.google.com/docs/firestore/quickstart which apparently was the one I needed but when I type on the app the line FirebaseFirestore firestore = FirebaseFirestore.getInstance();我一开始想使用页面https://firebase.google.com/docs/firestore/quickstart中的那个,这显然是我需要的,但是当我在应用程序上键入 FirebaseFirestore firestore = FirebaseFirestore.getInstance() ; I get the message error undefined class 'FirebaseFirestore'.我收到消息错误 undefined class 'FirebaseFirestore'。

What is it I am missing?我错过了什么? I have everything good on the pubspec.yaml, and all the packages are working我在 pubspec.yaml 上的一切都很好,所有的包都在工作

By the way I am trying to get the data so I can build based on this a dropdownbutton顺便说一句,我正在尝试获取数据,以便可以基于此构建一个下拉按钮

If you're not using timestamps, you can safely ignore it. 如果您不使用时间戳,则可以放心地忽略它。 This is probably the case since you're just starting to use it. 可能是这种情况,因为您才刚刚开始使用它。

It's a warning, rather than an error. 这是警告,而不是错误。 It's a reminder that if you use Firestore timestamps, you need to use the specified setting for the timestampsInSnapshots, which will break apps if not used. 提醒您,如果使用Firestore时间戳,则需要为timestampsInSnapshots使用指定的设置,如果不使用该设置,则会中断应用程序。

Import this:导入这个:

import 'package:cloud_firestore/cloud_firestore.dart';

And use this instead:并改用它:

FirebaseFirestore.instance

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM