Thanks for sharing your solution! Just a quick note for others who might run into this, this behavior happens because XML treats \n
as a literal backslash + n unless it's parsed or replaced explicitly in code. Flutter's tr()
function doesn't interpret escape sequences like \n
when reading from plain XML text.
Your workaround using replaceAll("\\n", "\n")
is a solid and clean fix, especially when you're maintaining centralized localization formatting. Just be mindful if your translations ever include actual backslashes, as this could cause unintended replacements. In JSON-based localization, this issue often doesn't come up since escape sequences are handled more naturally.
Hope this helps someone in the same boat!