【发布时间】:2021-12-03 11:41:25
【问题描述】:
您好,我正在尝试仅将列表中的一项复制到另一个列表中。
示例 1:
listFinalDevices = listDevices.map((index) => index).toList();
有点工作,但这每次都会覆盖listFinalDevice,我需要从listDevice中添加选定的项目。作为一种喜爱的设备列表。
示例 2:
listFinalDevices.insertAll(listFinalDevices.length,listDevices.map((index) => index).toList());
这将复制完整列表,但我只需要过度索引引用的项目。
谁能给我一个示例的链接或我必须搜索的关键字是什么。
更新: 为了更清楚,目前我在名为 listDevices 的列表中有以下数据:
[ScanResult{device: BluetoothDevice{id: 4D:55:F7:CE:03:FA, name: , type: BluetoothDeviceType.unknown, isDiscoveringServices: false, _services: [], advertisementData: AdvertisementData{localName: , txPowerLevel: null, connectable: true, manufacturerData: {}, serviceData: {0000fd6f-0000-1000-8000-00805f9b34fb: [215, 226, 39, 186, 231, 145, 9, 162, 217, 184, 33, 163, 133, 92, 23, 221, 40, 117, 217, 176]}, serviceUuids: [0000fd6f-0000-1000-8000-00805f9b34fb]}, rssi: -65}, ScanResult{device: BluetoothDevice{id: 00:80:E1:21:C4:B5, name: P2PSRV1, type: BluetoothDeviceType.le, isDiscoveringServices: false, _services: [], advertisementData: AdvertisementData{localName: P2PSRV1, txPowerLevel: null, connectable: true, manufacturerData: {33537: [0, 0, 32, 0, 0, 128, 225, 33, 196, 181]}, serviceData: {}, serviceUuids: []}, rssi: -35}, ScanResult{device: BluetoothDevice{id: 60:29:4D:9B:AC:52, name: , type: BluetoothDeviceType.unknown, isDiscoveringServices: false, _services: [], advertisementData: Adver
我的目标是,我选择了一些设备并将其放入一个应以 listFinalDevices 命名的收藏列表:
[ScanResult{device: BluetoothDevice{id: 00:80:E1:21:C4:B5, name: P2PSRV1, type: BluetoothDeviceType.le, isDiscoveringServices: false, _services: [], advertisementData: AdvertisementData{localName: P2PSRV1, txPowerLevel: null, connectable: true, manufacturerData: {33537: [0, 0, 32, 0, 0, 128, 225, 33, 196, 181]}, serviceData: {}, serviceUuids: []}, rssi: -35}, ScanResult{device: BluetoothDevice{id: C5:9F:97:96:4A:A9, name: MX Anywhere 2S, type: BluetoothDeviceType.le, isDiscoveringServices: false, _services: [], advertisementData: AdvertisementData{localName: MX Anywhere 2S, txPowerLevel: 4, connectable: false, manufacturerData: {}, serviceData: {}, serviceUuids: [00001812-0000-1000-8000-00805f9b34fb]}, rssi: -50}] is not empty
【问题讨论】:
-
欢迎@holgus。我不明白地图功能应该如何选择单个项目。你能澄清一下吗?
-
也许这会有所帮助:tutorialspoint.com/dart_programming/… 还可以查看官方 dart 语言导览,以更好地了解编程语言
-
我在描述中添加了更新
标签: list flutter dart copy add