The return type 'Map<String, MaterialApp>' isn't a 'MapEntry<_, _>', as required by the closure's context.怎么回事?
这个错误通常是由于在使用Map的forEach方法时,闭包的返回类型与需要的MapEntry类型不匹配所导致的。
解决方法是将闭包的返回类型更改为MapEntry类型,例如:
Map<String, MaterialApp> myMap = {...};
myMap.forEach((key, value) => MapEntry(key, value));
或者将forEach方法更改为for-in循环,例如:
Map<String, MaterialApp> myMap = {...};
for (var entry in myMap.entries) {
// do something with entry.key and entry.value
}
原文地址: https://www.cveoy.top/t/topic/ztY 著作权归作者所有。请勿转载和采集!