flutter - Flutter 上的数据转换
问题描述
朋友们,我正在使用以下方法从 WebService 中检索信息,该方法返回给我一个 MAP Future ˂Map ˂String, String >> recoverTypesBenefits () async {...
我想在 DropDown 中使用它,并尝试按如下方式恢复它:
DropdownButton (
isExpanded: false,
value: dropdownValueBeneficios,
items: (recoverTypesBenefits () as Map <String, String>). entries.map <DropdownMenuItem <String>> ((entry) {...
但我收到了这样的反馈:
type 'Future ˂Map ˂String, String >>' 不是类型转换中'Map ˂String, String>' 类型的子类型
我以为 MAP ˂String, String> 都不会出错。
细节:直接在 FUTURE 之外创建 MAP
Map <String, String> tipos = {"": "- Select the type of benefit -"};
,并以这种方式调用项目:tipos.entries.map ˂DropdownMenuItem ˂String>> ((entry) {... 我正确地恢复了数据。但是这种方式我不是动态地访问它的 web 服务。
任何人都可以帮忙吗?谢谢!
解决方案
推荐阅读
- android - 应用程序未运行时,AlarmManager SetExact() 未触发 - Android
- javascript - 是否有可能为 javascript 变量添加 nth-child?我需要将它添加到打字稿代码
- python - Python3 使用 Dict 和正则表达式替换字符串
- python - 在 django 环境中运行 requests_html 渲染函数时出现错误
- rust - 为什么这种重复模式在 Rust 宏中不起作用?
- c# - 实例化方法中传递的类型
- node.js - 基于 NestJS 中的异步配置有条件地导入内部模块
- python - 自动将所有字段从我的 sql db 获取到 django 模型?
- javascript - Firebase Cloud Messing错误:DOMException:无法在“窗口”上执行“atob”:要解码的字符串未正确编码
- android - 我可以使用一个数据类创建多个表吗?