After Updating to Flutter 3.7.0 i get this error message when i build my App:
[app_en.arb:scanCode_fieldNotMatched] ICU Syntax Error: Expected
"identifier" but found "0".
field to match is "{0}"
It seems as if something had changed in how the variables are written in the .arb localization files.
2
Answers
UPDATE 1: Escape syntax characters!
If what you are trying is to use the characters
{
,}
,'
(or any other syntax character for that matter) in your strings, then you will have to escape them. To do that enable theuse-escaping
flag by adding the following to l10n.yamlNow use pairs of single quotes to escape syntax characters, like "{". To escape single quotes you just have to write it as a double-single quote as follows:
More details on this in the flutter docu.
Update 2: If you are using a Chinese Mirror for Flutter
Follow details in this issue.
Original answer to my punctual problem
I found out that the reason for this error is that in Flutter 3.7
as stated in a release post.
Previously i was declaring strings in my .arb file as follows
where afterwards i was replacing
{0}
by some other value.Well, it seems that now the
gen-l10n
tool takes what is between brackets as special parameters, and the name"0"
is not accepted so i had to change my string toand
AppLocalizations
can be now called as:Further details on this can be found here: Placeholders, plurals, and selects in Flutter.
In my case, it was due to a translation string in my
arb
file forintl
package. I had:"{x, plural, =1{item}, other{items}}"
(worked fine in previous versions)This broke in Flutter 3.7. The solution for me was removing a comma:
"{x, plural, =1{item} other{items}}"
(works in Flutter 3.7)