【问题标题】:How could I enter third string to List<Map<String, String>> on Flutter?如何在 Flutter 上向 List<Map<String, String>> 输入第三个字符串?
【发布时间】:2021-06-11 22:56:18
【问题描述】:
  List<Map<String, String>> splashData = [
        {"text": "EGZERSİZİNİ SEÇ", "image": "assets/logo/Splash1.png"},
        {"text": "TELEFONUNU SABİTLE", "image": "assets/logo/Splash2.png"},
       {"text": "UYARI", "image": "assets/logo/Splash3.png"}
    ];

我正在尝试将 3 个字符串添加到 Flutter 中的列表。我怎样才能将第三个字符串添加到我的列表中?

我想做的例子

   List<Map<String, String, String> splashData :[
           {"text": "EGZERSİZİNİ SEÇ", "image": "assets/logo/Splash1.png","text1": "EGZERSİZİNİ SEÇ"},
           {"text": "TELEFONUNU SABİTLE", "image": "assets/logo/Splash2.png","text1":"EGZERSİZİNİ SEÇ"},
          {"text": "UYARI", "image": "assets/logo/Splash3.png","text1": "EGZERSİZİNİ SEÇ"}];

这个可以加吗?

感谢您的回复。

【问题讨论】:

    标签: list flutter dictionary


    【解决方案1】:

    您可以添加一个具有类似值的键。

    for(final Map<String, String> data in splashData){
      data['text1'] = 'EGZERSİZİNİ SEÇ';
    }
    

    【讨论】:

      【解决方案2】:
      splashData.forEach( (data) => data['text1'] = "EGZERSİZİNİ SEÇ"));
      

      【讨论】:

      • 请不要只发布代码作为答案,还要解释您的代码的作用以及它如何解决问题的问题。带有解释的答案通常更有帮助,质量更高,更有可能吸引投票。
      猜你喜欢
      • 2012-04-06
      • 2022-07-31
      • 2017-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多