Click here to Skip to main content
14,303,783 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello Everyone,

I would like to retrieve from my flutter/dart project, the current system lqnguage code, like. fr, en, ...

What I have tried:

I have tried the following:


Locale myLocale = Localizations.localeOf(context);
String lc = currentLanguageCode(myLocale);

print ("Language code: ${lc}");


The problen is from the void initState() statement, the context is null and will then return an empty string.

I was hoping to have a method like:
Platform.isIOS


Does anyonce have an idea how to grab this language code from everywhere in the project.

Thank you very much in advance.
Best regards.
MiQi
Posted
Comments
Kornfeld Eliyahu Peter 5-May-19 5:39am
   
Maybe this one: https://proandroiddev.com/flutter-localization-step-by-step-30f95d06018d

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100