Benjith Kizhisseri
Benjith Kizhisseri

Reputation: 2678

flutter get value from object and display in Text()

How to get value from an object in flutter? i need to display name of products in 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(),
            )

Upvotes: 1

Views: 2144

Answers (1)

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 658263

For complex expressions (not just simple identifiers) you need to use ${...} instead of $...

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

Upvotes: 1

Related Questions