1

I'm trying to add a text entry to "arb" file with an int placeholder but without success as I'm getting the follow error:

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.

The entry is the follow:

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

I know everything else is properly set because changing the placeholder to String things work:

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

running app

The complete code if you want to run is hosted on github here:

Working using String

Failing int branch

So my question is, how to use integer placeholder on arb file, it seems something related to NumberFormat but I can't figure out how.

ademar111190
  • 14,215
  • 14
  • 85
  • 114

2 Answers2

1

Add the format property should resolve this problem.

 "increment_message": "You have pushed the button this many times: {times}",
  "@increment_message": {
    "placeholders": {
      "times": {
        "type": "int",
        "format": "decimalPattern",
        "example": "123"
      }
    }
  }
iAMD
  • 21
  • 2
0

I have launched your repo (String and int branches) and everything works fine. Did you try flutter clean ?

Kamkle65
  • 29
  • 1
  • 3
  • Intriguing, yes I did try to clean, I'm wondering which flutter version you are using. – ademar111190 Nov 23 '21 at 12:17
  • Oh dear, that is it, I was running on `Flutter 2.2.3` and `Dart 2.13.4`, updating to `Flutter 2.5.2` and `Dart 2.14.3` it is working for me too, thank you for reporting it. – ademar111190 Nov 23 '21 at 12:24