Flutter 错误:应为类型为';地图<;动态,动态>';,但是得到了一个类型';列表<;动态>';
我正在使用软件包并尝试在色调桥中向我显示已实现的灯光,但出现以下错误:Flutter 错误:应为类型为';地图<;动态,动态>';,但是得到了一个类型';列表<;动态>';,flutter,dart,hue,Flutter,Dart,Hue,我正在使用软件包并尝试在色调桥中向我显示已实现的灯光,但出现以下错误: Instance of `_Future<List<Light>>` Error: Expected a value of type `Map<dynamic, dynamic>', but got one of type 'List<dynamic>' 未来的实例`\u` 错误:应为“Map”类型的值,但得到了“List”类型的值 如何将此列表转换为地图,或如何显示灯光列
Instance of `_Future<List<Light>>`
Error: Expected a value of type `Map<dynamic, dynamic>', but got one of type 'List<dynamic>'
未来的实例`\u`
错误:应为“Map”类型的值,但得到了“List”类型的值
如何将此列表转换为地图,或如何显示灯光列表
这是我的代码:
class HueBridge {
searchBridge() async {
final client = Client();
final discovery = BridgeDiscovery(client);
List<DiscoveryResult> discoverResults = await discovery.automatic();
final discoveryResult = discoverResults.first;
final bridge = Bridge(client, discoveryResult.ipAddress);
print(discoveryResult.ipAddress);
final lights = bridge.lights();
print(lights);
}
}
HueBridge类{
searchBridge()异步{
最终客户机=客户机();
最终发现=BridgeDiscovery(客户端);
List discoverResults=wait discovery.automatic();
最终发现结果=发现结果。第一;
最终网桥=网桥(客户端,discoveryResult.ipAddress);
打印(discoveryResult.ipAddress);
最终灯光=bridge.lights();
印刷(灯光);
}
}
在调试终端中显示出现错误的当前行,你能写这行吗?当我添加
final lights=bridge.lights()时会发生这种情况代码>。这就是这个包的文档告诉我如何搜索连接到网桥的灯光。