使用Flutter本地化从字符串转换为列表

时间:2019-11-25 12:19:58

标签: flutter dart flutter-dependencies

我有一组不同的单词列表。所有这些都经过翻译,其结构如下:

{
  "default_sets": [
    {
      "title": "Animals",
      "elements": [
        "Squirrel",
        "Dog",
       ]
    },
    {
      "title": "Cities",
      "elements": [
        "Madrid",
        "London",
       ]
    }
}

要动态获取此翻译集,请执行以下操作: AppLocalizations.of(context).translate('default_sets'),但返回的内容如下:

[{title: Animals, elements: [Squirrel, Dog...

我收到此错误:

Unexpected character (at character 3)
[{title: Animals, elements: [Squirrel, Dog...
  ^

我知道这是因为翻译删除了引号而引起的,但是我可以同时翻译和解码吗?

0 个答案:

没有答案