【问题标题】:flutter get value from object and display in Text()flutter 从对象中获取值并显示在 Text() 中
【发布时间】:2019-06-14 19:33:22
【问题描述】:

如何从颤动的对象中获取价值?我需要在 Text() 中显示产品名称

List<Object> _dataResponse = [
{"item":"chakka"},
{"item":"manga"},
{"item":"thenga"},
];

 ListView(
              children: _productName
                  .map((f) => ListTile(
                        leading:  Icon(Icons.check_circle,color: Colors.green,),
                        title:  **Text('$f["item"]')**,

                      ))
                  .toList(),
            )

【问题讨论】:

    标签: flutter


    【解决方案1】:

    对于复杂的表达式(不仅仅是简单的标识符),您需要使用${...} 而不是$...

    Text('${f["item"]}')
    

    【讨论】:

    • 谢谢。我也把List&lt;Object&gt;改成了List&lt;Map&gt;
    猜你喜欢
    • 1970-01-01
    • 2018-09-10
    • 1970-01-01
    • 1970-01-01
    • 2017-01-09
    • 2017-03-27
    • 2019-05-07
    • 2021-12-24
    • 2013-06-04
    相关资源
    最近更新 更多