Flutter 如何从列表中将值设置为Firestore
我正在尝试制作一个评分应用程序,我想列出Firestore的学生并填写他们的成绩,我已经得到了学生名单的列表,但我无法得到工作的编号我有一个只使用布尔值的工作出勤代码 这是布尔人的工作代码Flutter 如何从列表中将值设置为Firestore,flutter,dart,google-cloud-firestore,Flutter,Dart,Google Cloud Firestore,我正在尝试制作一个评分应用程序,我想列出Firestore的学生并填写他们的成绩,我已经得到了学生名单的列表,但我无法得到工作的编号我有一个只使用布尔值的工作出勤代码 这是布尔人的工作代码 Switch( value: switchStates[ students[index].data()["id"]],
Switch(
value: switchStates[
students[index].data()["id"]],
onChanged: (value) {
setState(() {
stateofvalue = value;
});
onSwitchChanged(
students[index].data()["id"], value);
},
activeColor: Color(0xff2fbd9f),
),
这就是我所说的值
CollectionReference users = FirebaseFirestore.instance.collection('users');
Future<void> markAttendance() {
Map<String, dynamic> resultMap = {};
var formatter = new DateFormat('dd-MM-yyyy');
String todaysDate = formatter.format(now);
switchStates.forEach((key, value) {
keys.add(key);
values.add(value);
});
for (var i = 0; i < keys.length; i++) {
resultMap["${keys[i]}"] = values[i];
}
FirebaseFirestore.instance
.collection("data")
.doc("attendance")
.collection("school")
.doc(todaysDate)
.set(resultMap);
}
CollectionReference users=FirebaseFirestore.instance.collection('users');
未来出席人数(){
映射结果映射={};
var formatter=new DateFormat('dd-MM-yyyy');
String todaysDate=formatter.format(现在);
switchStates.forEach((键,值){
key.add(key);
增加(价值);
});
对于(变量i=0;i
这就是我设置th值的方式,但是现在我想用同样的方式设置等级,我如何用
TextField()替换Switch()
尝试使用TextField
和onSubmitted
或onChanged
回调来设置等级
TextField(
controller: _controller,
onSubmitted: (text) {
sendMessage(text);
_controller.clear();
},
onChanged: () {},
textInputAction: TextInputAction.send,
)
如果您有用户ID,您可以尝试以下操作
Firestore.instance
.collection("users")
.document(userId)
.get().then((value) => value.update({
field: value
})
我的意思是,获取集合,然后单独更新它每个学生有多少个分数?每个学生只有一个总分吗?还是每个学生都有不同课程的多个等级?你希望进入哪种等级?为了简单起见,您可以使用下拉列表!但是我怎样才能让它工作呢