[英]Android studio says “FirebaseFirestore class file not found”
[英]flutter undefined class 'FirebaseFirestore'
我正在尝试将数据从 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);
我正在使用包
import 'package:flutter/material.dart';
import 'auth.dart';
import 'state_rut.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
获取信息的代码如下:
final collection = Firestore.instance.collection('regions');
collection.orderBy('region_id').getDocuments()
.then((data){
print(data);
})
.catchError((e){
print(e);
});
我一开始想使用页面https://firebase.google.com/docs/firestore/quickstart中的那个,这显然是我需要的,但是当我在应用程序上键入 FirebaseFirestore firestore = FirebaseFirestore.getInstance() ; 我收到消息错误 undefined class 'FirebaseFirestore'。
我错过了什么? 我在 pubspec.yaml 上的一切都很好,所有的包都在工作
顺便说一句,我正在尝试获取数据,以便可以基于此构建一个下拉按钮
如果您不使用时间戳,则可以放心地忽略它。 可能是这种情况,因为您才刚刚开始使用它。
这是警告,而不是错误。 提醒您,如果使用Firestore时间戳,则需要为timestampsInSnapshots使用指定的设置,如果不使用该设置,则会中断应用程序。
导入这个:
import 'package:cloud_firestore/cloud_firestore.dart';
并改用它:
FirebaseFirestore.instance
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.