简体   繁体   English

Flutter,未为类型“Object”定义方法“containsKey”

[英]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.

相关问题 方法“of”没有为类型“ThemeProvider”定义。 在 Flutter - The method 'of' isn't defined for the type 'ThemeProvider'. in Flutter 没有为类型“function”定义方法“containsKey”。 我该如何解决? - The method 'containsKey' isn't defined for the type 'function'. How can I fix it? Flutter 方法 'then' 没有为类型 'User' 定义 - Flutter The method 'then' isn't defined for the type 'User' FLUTTER 未为“对象”类型定义运算符“[]” - FLUTTER The operator '[]' isn't defined for the type 'Object' Flutter 错误 - 未为该类型定义方法“setState” - Flutter Error - Method 'setState' isn't defined for the type Flutter 错误:没有为“ScreenUtil”类型定义方法“setContext” - Flutter Error: The method 'setContext' isn't defined for the type 'ScreenUtil' “没有为类型‘DatabaseReference’定义方法‘getDocuments’。” Flutter - Firebase - “The method 'getDocuments' isn't defined for the type 'DatabaseReference'.” Flutter - Firebase Dart/Flutter:没有为类型“List”定义方法“foldIndexed” - Dart/Flutter: Method 'foldIndexed' isn't defined for the type 'List' 没有为“患者”飞镖颤振类型定义“fromSnapshot”方法 - The method 'fromSnapshot' isn't defined for the type 'Patient' dart flutter 没有为“CollectionReference”类型定义方法“document”。 颤振/火力基地 - The method 'document' isn't defined for the type 'CollectionReference'. Flutter/Firebase
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM