小编edi*_*oth的帖子

使用 GlobalMaterialLocalizations.delegate 提供错误

编辑:答案很简单:

await initializeDateFormatting('pl_PL');
Run Code Online (Sandbox Code Playgroud)

上面的代码与以下内容发生冲突:

GlobalMaterialLocalizations.delegate
Run Code Online (Sandbox Code Playgroud)

删除 initializeDateFormatting 有帮助。


我在我的 Flutter 应用程序上进行了本地化。不幸的是,当我添加GlobalMaterialLocalizations.delegatelocalizationsDelegates出现错误。删除GlobalMaterialLocalizations.delegate提供应用程序正常工作,但只有英文版本。另一种语言(波兰语)与 AppBars 有问题(再次 - 删除它后(appbar)应用程序在该语言中也能正常工作)。

我的部分代码:

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

错误:

不支持的操作:无法在不可修改的 Map 中设置值

当我评论 GlobalMaterialLocalizations.delegate(页面有 AppBar)时出现错误:https : //pastebin.com/ENF5ZET7

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

flutter

21
推荐指数
2
解决办法
5305
查看次数

标签 统计

flutter ×1