I Hope anyone can help..
How to format number with thousand separator whil this’s data get form API.
My Code is like this:
Future<List<Data>> fetchData() async {
var url = Uri.parse('https://bps-3301-asap.my.id/api/sensus-tani-rtup');
final response = await http.get(url);
if (response.statusCode == 200) {
var cokk = jsonDecode(response.body);
return (cokk['data'] as List).map((data) => Data.fromJson(data)).toList();
} else {
throw Exception('Unexpected error occured!');
}
}
I wanto display data from that API with separate thousand (with ".").
this the code in data table:
DataCell(
Text(
data.rtup.toString(),
style: const TextStyle(
color: Color.fromARGB(255, 17, 17, 17),
fontWeight: FontWeight.normal,
fontSize: 12,
),
),
),
I want to display rtup and other data cell get from API as number with thousand sepatator. Try many way but still fail.
very appreciated for any one can help. Txh U
Output right now:
enter image description here
Ouput what i want is all the number display with ("." for thusand) like
11.171
18.197
I use formatter with package intl before (and it’s work), but now i m working with datable while datacell get data from API.
PS: Sorry for my english
2
Answers
Thx man! Finally it's work i've already make a function
i m just add double.tryParse
(Format.convertTo( double.tryParse(data.pangan_rtup), 0)), –
Thx again.
You can use "intl" package for this.
Just add intl to your project and import it. Then you can use it like this
For this example I have used intl: ^0.17.0.
And I have created a method for changing number. Just call this method in your view.