Hardik
Hardik

Reputation: 434

Convert Dart List of Double or Int to List of String

I have:

List<double> prices = [20.5, 10.0, 18.6, 41.8];

I need as Parameter Value:

pricesString : ["20.5", "10.0", "18.6", "41.8"],

Upvotes: 0

Views: 1475

Answers (2)

Hardik
Hardik

Reputation: 434

pricesString : prices.map((e) => e.toString()).toList(),

Which is passing the following list:

pricesString : ["20.5", "10.0", "18.6", "41.8"]

Upvotes: 3

Unes
Unes

Reputation: 90

List<String> prices = List.generate(firtList.length,(i) => firtList[i].toString());

Upvotes: 0

Related Questions