0

我正在尝试使用 int 占位符将文本条目添加到“arb”文件,但没有成功,因为我收到以下错误:

Number format null for the times placeholder does not have a corresponding NumberFormat constructor.
Check the intl library's NumberFormat class constructors for allowed number formats.
Generating synthetic localizations package has failed.

条目如下:

  "increment_message": "You have pushed the button this many times: {times}",
  "@increment_message": {
    "placeholders": {
      "times": {
        "type": "int",
        "example": "123"
      }
    }
  }

我知道其他所有内容都已正确设置,因为将占位符更改为 String 可以正常工作:

  "increment_message": "You have pushed the button this many times: {times}",
  "@increment_message": {
    "placeholders": {
      "times": {
        "type": "String",
        "example": "123"
      }
    }
  }

运行应用

如果要运行,完整的代码托管在 github 上:

使用字符串工作

失败的int分支

所以我的问题是,如何在 arb 文件上使用整数占位符,这似乎与此有关,NumberFormat但我不知道如何。

4

2 回答 2

0

添加格式属性应该可以解决这个问题。

 "increment_message": "You have pushed the button this many times: {times}",
  "@increment_message": {
    "placeholders": {
      "times": {
        "type": "int",
        "format": "decimalPattern",
        "example": "123"
      }
    }
  }
于 2022-01-11T11:20:52.883 回答
0

我已经启动了你的 repo(字符串和 int 分支)并且一切正常。你试过了flutter clean吗?

于 2021-11-23T07:21:24.937 回答