本文介绍了使用GlobalMaterialLocalizations.delegate提供错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

答案很简单:

await initializeDateFormatting('pl_PL');

以上代码与以下内容冲突:

Above code was in conflict with:

GlobalMaterialLocalizations.delegate

删除initializeDateFormatting帮助.

Removing initializeDateFormatting helps.

我在Flutter应用上进行了本地化.不幸的是,当我将GlobalMaterialLocalizations.delegate添加到localizationsDelegates时,出现错误.删除GlobalMaterialLocalizations.delegate可使应用正常运行,但只能使用英文版本.另一种语言(波兰语)对AppBars有问题(再次-删除它(appbar)后,该应用程序也可以在该语言下正常工作.)

I made a localization on my Flutter app. Unfortunately when I add GlobalMaterialLocalizations.delegate to localizationsDelegates there is an error. Removing GlobalMaterialLocalizations.delegate provides app to work correctly but only English version. Another language (Polish) has a problem with AppBars (Again - after removing it (appbar) app works fine in that language too).

部分代码:

localizationsDelegates: [
  const ReadyLocalizationsDelegate(),
  GlobalMaterialLocalizations.delegate,
  GlobalWidgetsLocalizations.delegate,
],
supportedLocales: [
  const Locale('en', 'US'),
  const Locale('pl', 'PL'),
],

错误:

当我评论GlobalMaterialLocalizations.delegate(页面具有AppBar)时,这是一个错误: https://pastebin.com/ENF5ZET7

Here is an error when I comment GlobalMaterialLocalizations.delegate (page has AppBar):https://pastebin.com/ENF5ZET7

正如我所说,将本地化设置为英语时没有错误.

As I said there is no error when localization is set to English.

推荐答案

await initializeDateFormatting('pl_PL');

以上代码与以下内容冲突:

Above code was in conflict with:

GlobalMaterialLocalizations.delegate

删除initializeDateFormatting帮助.

Removing initializeDateFormatting helps.

这篇关于使用GlobalMaterialLocalizations.delegate提供错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 16:31