firebase - 未处理的异常:类型“布尔”不是“字符串”类型的子类型
问题描述
我想修改这个标题错误。
你有什么解决办法吗。
主要.dart
Padding(
padding: const EdgeInsets.only(top: 20),
child: Text(workout.reportList,
style: TextStyle(fontSize: 12)),
),
main_model.dart
List<String> reportList = [
"Not relevant",
"Illegal",
"Spam",
"Offensive",
"Uncivil"
];
Future add(model) async {
final collection = FirebaseFirestore.instance.collection('workoutlist');
await collection.add({
'title': newWorkoutText,
'count': int.parse(newWorkoutDigit),
"category": reportList,
'createdAt': Timestamp.now(),
});
add_page.dart
List<String> reportList;
List<String> selectedChoices = List();
Container(
padding: const EdgeInsets.all(8.0),
child: ChoiceChip(
label: Text(model.reportList.toString()),
selected: isSelected,
selectedColor: Colors.teal,
onSelected: (selected) {
setState (() {
isSelected = selected;
});
},
),
锻炼.dart
Workout(DocumentSnapshot doc) {
this.documentReference = doc.reference;
this.reportList = doc.data()['category'].toString();
}
String reportList;
bool isDone = false;
我想分离这些组件,但现在收集了这个列表
解决方案
reportList
不是一个String
,是一个List
。如果将值传递给Text
小部件,则值必须是String
.
推荐阅读
- javascript - 如何使用带有 Acrobat XI 的 JavaScript 仅编辑最后修改的注释 (Ink)?
- linux - Linux按行数溢出的文本文件将换行符保留在适当的位置
- javascript - 将文本存储为变量,然后根据变量值更改 css 样式
- dart - Dart sqljocky 的问题
- hadoop - 将目录从远程 HDFS 本地文件系统复制到我的本地计算机
- python - Folium Polylines 使用 Python 连接绘图
- plotly - plotly.js 3D散点图中的动画
- python - 如何在 DRF 的 Browsable API 中针对当前用户过滤 ManyToManyField?
- laravel - 带有后缀的 Laravel
- javascript - Javascript 在单击按钮时多次打开链接