You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter中如何打印Map数据里的"it"和"mt"对应值?

解决方案

步骤说明

  1. 从外层Map中通过key "value" 获取内层的嵌套Map
  2. 分别使用"it"和"mt"作为key,从内层Map中取出对应的整数列表
  3. 直接打印取出的列表内容

Java 代码示例

import java.util.List;
import java.util.Map;

public class PrintMapValues {
    public static void main(String[] args) {
        Map<String, Map<String, List<Long>>> data = Map.of(
            "value", Map.of(
                "it", List.of(1666117800000L, 1666204200000L, 1666290600000L),
                "mt", List.of(1666463400000L, 1666549800000L, 1666636200000L)
            )
        );

        Map<String, List<Long>> innerMap = data.get("value");
        System.out.println("it对应的列表值: " + innerMap.get("it"));
        System.out.println("mt对应的列表值: " + innerMap.get("mt"));
    }
}

Dart 代码示例

void main() {
  Map<String, Map<String, List<int>>> data = {
    "value": {
      "it": [1666117800000, 1666204200000, 1666290600000],
      "mt": [1666463400000, 1666549800000, 1666636200000]
    }
  };

  var innerMap = data["value"];
  print("it对应的列表值: ${innerMap?["it"]}");
  print("mt对应的列表值: ${innerMap?["mt"]}");
}

内容的提问来源于stack exchange,提问作者Ashu Upadhyay

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 01:20:21