[英]Flutter, The method 'containsKey' isn't defined for the type 'Object'
documentSnapshot.data().containsKey("fieldName")
I updated Flutter from 2.23 to 2.8我将 Flutter 从 2.23 更新到 2.8
and suddenly red line occurs突然出现红线
and the error message is错误信息是
The method 'containsKey' isn't defined for the type 'Object'.
There is a red line under containsKey How to solve this? containsKey下面有一条红线怎么解决?
Had the same issue, convert to the type of the data works.有同样的问题,转换为数据类型有效。
final docData = docSnapshot.data() as Map<String, dynamic>;
if (docSnapshot.exists && !docData.containsKey('labels')) {
return;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.