Get device currency with Flutter - flutter

I have a question about currencies. How can I get device currency based on region, location or something like this? There are cases when (for example) device language (and locale) set to English, but currency is Euro or Peso. Currently I'm using NumberFormat which is based on localeCode, but it generates errors for some regions.
For example
country: Ukraine,
language: Russian,
currency: Russian ruble <- wrong. Should be Ukrainian hryvna.
I don't know how, but Google Play deals with this problem :) So I think it should be also possible for other apps.

Have you tried the following, it should work with Ukrainian hryvna:
import 'dart:io';
import 'package:intl/intl.dart';
String currency = NumberFormat.simpleCurrency(locale: Platform.localeName).currencySymbol;

Related

Issue while using "Contact_Service" package to get contacts to phone in One format only

Anyone have experince or face following issue while using "Contact_Service" package to get contacts to phone..
This package gives us all our contact but when i want to get phone number of any contact, it gives in different format like +92, 0340, +91, 00012 etc. It gives format according to which its saved....But I want all phone numbers to be in One same format that's is International Format starting from "+". So if number is saved with 0340...it should convert it to +92340
Did any of you faced this issue while dealing with contacts of phone
You solve your issue by adding +92 to the number that come from Contact_Service
Such like this
yourNumber="+65435435"
number="+92$yourNumber"

Format all the numbers on an app [Flutter]

Is there any way to format all the numbers on a flutter app?
By formatting I mean, for example, given a number (eg 4000) it’s shown on the UI as 4,000.
I know that there’s a way to do so using the intl package, but in that case, from what I know, I have to format each number individually and it’s not the most optimal thing to do in my case.
You can use NumberFormat passing a custom format in ICU formatting pattern, take a look in NumberFormat.
import 'package:intl/intl.dart';
void main() {
var formatter = NumberFormat('#,##,000');
print(formatter.format(16987));
print(formatter.format(13876));
print(formatter.format(456786));
}
Output
16,987
13,876
4,56,786

Flutter Dart - get localized country name from country code

I have a list of alpha-2 country codes.
List<String> countryCodes = ["DE", "CH", "AT"];
How to get the localized country names in Flutter/Dart?
If the device language is set to english, i want this output..
Germany, Switzerland, Austria
If the device language is set to german, i want this output..
Deutschland, Schweiz, Österreich
Is this possible without any 3rd party package in Flutter/Dart?
In Java you could do..
Locale loc = new Locale("","DE");
loc.getDisplayCountry();
To get the localized country names from a country code one can use the Country Codes package from pub.dev.
Its easy to use. I recommend.
https://pub.dev/packages/country_codes

Flutter compactCurrency for Indian rupees but need to display lakhs, crores in English

I am using NumberFormat.compactCurrency() with HI locale as I want to compact the number in the Indian currency way - into lakhs, crores..etc.
But, if I use HI as the locale in it, it seems to add the lakh/crore string in Hindi. I want to compact the currency in the Indian way but show the lakh/crore in English. Do I need to use a different locale string for that? any other ideas?
The most simple way to get closest to your requirements would be to use  en_IN:
NumberFormat.compactCurrency(locale: 'en_IN').format(price)
Output :

What format is required to import a date into google spreadsheet

With the help of "stackoverflow" and it's users I'm using an app to import data into a Google spreadsheet. The problem is I have a date question on the form, and can not manage to import it. If I change the format (in the forms) to text, the data imports as it has been sent from the app, but when I change it back to date, nothing.
I've believe I've tried all the usual date formats (dd/mm/yyyy, mm/dd/yyyy, yyyy/mm/dd, yyyy/dd/mm) as well as yy for the above and also numerical.
I know that the Google form shows the date in the users format and that is not a problem. It shows up correctly in the spreadsheet in my local format (dd/mm/yyyy).
Does anyone know what format the form uses to send the data to the spreadsheet, or anyway to find out.
Thanks in advance.
Ok, after using wikipedia, and trying every different format it works by using the format yyyy-mm-dd