方法 'document' 没有为类型 'CollectionReference' 定义。 Flutter/Firebase
The method 'document' isn't defined for the type 'CollectionReference'. Flutter/Firebase
方法 'document' 没有为类型 'CollectionReference' 定义。
尝试将名称更正为现有方法的名称,或定义名为 'document'.
的方法
我在我的项目中遇到了这个错误。你能帮帮我吗?
我的代码:
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:crypto_app/models/users.dart';
class FireStoreService {
final FirebaseFirestore _firestore = FirebaseFirestore.instance;
final DateTime time = DateTime.now();
Future<void> createUser({id, mail, userName, photoUrl = ""}) async {
await _firestore.collection("users").doc(id).set({
"userName": userName,
"mail": mail,
"photoUrl": photoUrl,
"about": "",
"createTime": time
});
}
Future<Users> bringUser(id) async {
DocumentSnapshot doc = await _firestore.collection("users").doc(id).get();
if (doc.exists) {
Users users = Users.dokumandanUret(doc);
return users;
}
return null;
}
void userUpdate({String userId, String userName, String photoUrl = ""}) {
_firestore
.collection("users")
.document(userId)
.updateData({"userName": userName, "photoUrl": photoUrl});
}
}
CollectionReference
in cloud_firestore
for flutter/dart 没有 document(..)
方法。它被称为 doc(..)
。 https://pub.dev/documentation/cloud_firestore/latest/cloud_firestore/CollectionReference/doc.html
方法 'document' 没有为类型 'CollectionReference' 定义。 尝试将名称更正为现有方法的名称,或定义名为 'document'.
的方法我在我的项目中遇到了这个错误。你能帮帮我吗?
我的代码:
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:crypto_app/models/users.dart';
class FireStoreService {
final FirebaseFirestore _firestore = FirebaseFirestore.instance;
final DateTime time = DateTime.now();
Future<void> createUser({id, mail, userName, photoUrl = ""}) async {
await _firestore.collection("users").doc(id).set({
"userName": userName,
"mail": mail,
"photoUrl": photoUrl,
"about": "",
"createTime": time
});
}
Future<Users> bringUser(id) async {
DocumentSnapshot doc = await _firestore.collection("users").doc(id).get();
if (doc.exists) {
Users users = Users.dokumandanUret(doc);
return users;
}
return null;
}
void userUpdate({String userId, String userName, String photoUrl = ""}) {
_firestore
.collection("users")
.document(userId)
.updateData({"userName": userName, "photoUrl": photoUrl});
}
}
CollectionReference
in cloud_firestore
for flutter/dart 没有 document(..)
方法。它被称为 doc(..)
。 https://pub.dev/documentation/cloud_firestore/latest/cloud_firestore/CollectionReference/doc.html