如何在flutter中检索当前语言代码 [英] How to retrieve the current language code in flutter
问题描述
Hello Everyone,
我想从我的flutter / dart项目中检索当前的系统lqnguage代码,就像。 fr,en,...
我尝试过:
我尝试过以下方法:
Locale myLocale = Localizations.localeOf(context);
String lc = currentLanguageCode(myLocale);
打印(语言代码:$ {lc});
问题来自< b> void initState()语句,上下文为null,然后返回一个空字符串。
我希望有一个像这样的方法: pre> Platform.isIOS
是否有人知道如何从项目的各个角落获取此语言代码。 />
非常感谢您。
祝你好运。
MiQi
{lc});
问题来自 void initState()语句,上下文为空,然后返回一个空字符串。
我希望有一个方法,如:平台。 isIOS
任何人都知道如何从项目的任何地方获取此语言代码。
非常感谢您。
祝你好运。
MiQi
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
{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
这篇关于如何在flutter中检索当前语言代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!