如何在flutter中找到地图最大值的键?

用户12034457

这是所需的地图。我希望输出是中性的。

{anger: 0.0, contempt: 0.02, disgust: 0.0, fear: 0.0, happiness: 0.0, neutral: 0.978, sadness: 0.002, surprise: 0.0}
巴勃罗·兰扎·莫雷诺
Map themap={"anger": 0.0, "contempt": 0.02, "disgust": 0.0, "fear": 2.0, "happiness": 0.0, "neutral": 0.978, "sadness": 0.002, "surprise": 0.0};

    var thevalue=0.0;
    var thekey;

    themap.forEach((k,v){
      if(v>thevalue) {
        thevalue = v;
        thekey = k;
      }
    });

    print (thekey);

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章