sim*_*mer 2 localization flutter
我有一个仅适用于非英语语言环境的应用程序,因此它在 Text 对象中包含硬编码字符串。我正在尝试本地化 showDatePicker()
如果我尝试传递localizationsDelegates: [GlobalMaterialLocalizations.delegate]给 MaterialApp,则会出现异常。
如果我尝试传递locale: const Locale("es")给 showDatePicker 而不传递localizationDelegates给MaterialApp,则会出现异常。
I've solved it.
Pass these arguments to the materialApp:
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate, // ONLY if it's a RTL language
],
supportedLocales: const [
Locale('fr', 'FR'), // include country code too
],
Run Code Online (Sandbox Code Playgroud)
And since the locale is already defined, it's not necessary to pass it to showDatePicker.
| 归档时间: |
|
| 查看次数: |
1592 次 |
| 最近记录: |