Localizely logo
  • Home
  • Getting started
  • How it works
  • Pricing
  • FAQ
Sign up

I18n questions · Flutter

How to get a localization message with a dynamic string key value in Flutter? 

Dart does not have square brackets property accessor (object['property']) on class instances.
Therefore, it is not possible to access localization messages in that way.

Correct:

AppLocalizations.of(context)!.stringKey

Wrong:

AppLocalizations.of(context)!['stringKey']

However, if you want to access a certain message according to the value of a variable (e.g. the value returned from the server), you can use the ICU Select type of messages. These messages work well with a smaller set of predefined values like constants and enums.

Localization message in arb file:

{
  "selectExample": "{choice, select, foo {Foo} bar {Bar} other {Other}}",
  "@selectExample": {
    "placeholders": {
      "choice": {}
    }
  }
}

Access the localization message in code:

AppLocalizations.of(context)!.selectExample('bar')

Note: Explore ICU messages using the ICU Message Editor.

Published Feb 1, 2023 · Last reviewed Oct 9, 2026 · Markdown version

Related Flutter internationalization questions:

Flutter internationalization tutorial:

Learn about internationalization in Flutter
Localizely logo
About
Free tools
Boring stuff
  • Privacy Policy
  • Terms of Service
  • Cookie Policy
Newsletter
Copyrights 2026 © Localizely