Problem
I was working on an app targeted for Germany. And in German locale 12.5
is written 12,5
, 1.050
in German means one thousand and fifty
.
Solution
I created 2 utility functions 1st to parse double to de
locale and second to convert back to double.
Here is the code
import 'package:intl/intl.dart'; static String deFormat (String val) { final deFormat = NumberFormat.decimalPattern('de',); return deFormat.format(double.parse(val)); } static num enFormat (String val) { final deFormat = NumberFormat.decimalPattern('de',); return deFormat.parse(val); }
You'll need intl package.
Top comments (0)