当我将语言设置为“马来西亚”时,显示错误

时间:2018-05-02 03:45:35

标签: android flutter

I/flutter ( 4941): The getter 'openAppDrawerTooltip' was called on null. I/flutter ( 4941): Receiver: null I/flutter ( 4941): Tried calling: openAppDrawerTooltip I/flutter ( 4941): Another exception was thrown: NoSuchMethodError: The getter 'openAppDrawerTooltip' was called on null. I/flutter ( 4941): Another exception was thrown: NoSuchMethodError: The getter 'signedInLabel' was called on null.

切换到马来语时为什么会出现此错误?

我支持的语言是

`static Iterable<Locale> get supportedLocales => [
    const Locale('en', 'US'),
    const Locale('ms', 'MY'),
    const Locale('zh', 'CN'),
];`

1 个答案:

答案 0 :(得分:0)

Malasia尚不支持

https://github.com/flutter/flutter/blob/286cdf43f018583e84ded36e0eb26211db6bdd3f/packages/flutter_localizations/lib/src/material_localizations.dart#L42-L65

支持的语言

///   * ar - Arabic
///   * de - German
///   * en - English
///   * es - Spanish
///   * fa - Farsi
///   * fr - French
///   * he - Hebrew
///   * id - Indonesian
///   * it - Italian
///   * ja - Japanese
///   * ko - Korean
///   * ms - Malay
///   * nl - Dutch
///   * no - Norwegian
///   * pl - Polish
///   * ps - Pashto
///   * pt - Portuguese
///   * ro - Romanian
///   * ru - Russian
///   * th - Thai
///   * tr - Turkish
///   * ur - Urdu
///   * vi - Vietnamese
///   * zh - Simplified Chinese

另见https://github.com/flutter/flutter/tree/master/packages/flutter_localizations/lib/src/l10n

https://github.com/flutter/flutter/pull/12645显示了如何添加自定义本地化的示例

class PolishLocalizationsDelegate extends LocalizationsDelegate<MaterialLocalizations> {
  const PolishLocalizationsDelegate();

  @override
  bool isSupported(Locale locale) => locale.languageCode == 'pl';

  @override
  Future<MaterialLocalizations> load(Locale locale) => MyPolishMaterialLocalizations.load(locale);

  @override
  bool shouldReload(PolishLocalizationsDelegate old) => false;
}
new MaterialApp(
  localizationsDelegates: [
    const PolishLocalizationsDelegate(),
    GlobalMaterialLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
  ],
  supportedLocales: [
    const Locale('pl', 'PL'),
    // .. the other supported locales here
  ]
)