首页 > 解决方案 > 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 服务。

任何人都可以帮忙吗?谢谢!

标签: flutterdart

解决方案


推荐阅读