flutter 如何将多个{"conditionId": "", "deviceId": 1663743185928585216, "ieeeAddress": "CC86ECFFFE5CDCD9", "endpoint": 4, "deviceType": "A010401000000", "state": 1, "temperature": 0, "humidity": 0, "cron": "*"}添加为一个数组
时间: 2023-07-03 12:24:59 浏览: 121
platform_device_id:Flutter插件获取设备ID
可以使用List来存储多个相同结构的Map。在Flutter中,可以这样定义一个包含多个相同结构Map的List:
```
List<Map<String, dynamic>> dataList = [
{"conditionId": "", "deviceId": 1663743185928585216, "ieeeAddress": "CC86ECFFFE5CDCD9", "endpoint": 4, "deviceType": "A010401000000", "state": 1, "temperature": 0, "humidity": 0, "cron": "*"},
{"conditionId": "", "deviceId": 1663743185928585217, "ieeeAddress": "CC86ECFFFE5CDCD8", "endpoint": 4, "deviceType": "A010401000000", "state": 1, "temperature": 0, "humidity": 0, "cron": "*"},
{"conditionId": "", "deviceId": 1663743185928585218, "ieeeAddress": "CC86ECFFFE5CDCD7", "endpoint": 4, "deviceType": "A010401000000", "state": 1, "temperature": 0, "humidity": 0, "cron": "*"}
];
```
在这个例子中,我们定义了一个包含三个相同结构的Map的List,每个Map包含了conditionId、deviceId、ieeeAddress等相同的key-value对。你可以根据需要修改Map中的值,或者添加/删除Map来实现你的需求。
阅读全文