---
title: "How to get a localization message with a dynamic string key value in Flutter?"
description: "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. 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."
category: flutter
date: 2023-02-01
updated: 2026-10-09
canonical: https://localizely.com/i18n-questions/flutter/how-to-get-a-localization-message-with-a-dynamic-string-key-value-in-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:  
```dart
AppLocalizations.of(context)!.stringKey
```

Wrong:  
```dart
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](/blog/quick-guide-to-icu-message-format/#select) type of messages. These messages work well with a smaller set of predefined values like constants and enums.

Localization message in arb file:
```json
{
  "selectExample": "{choice, select, foo {Foo} bar {Bar} other {Other}}",
  "@selectExample": {
    "placeholders": {
      "choice": {}
    }
  }
}
```

Access the localization message in code:
```dart
AppLocalizations.of(context)!.selectExample('bar')
```
> Explore ICU messages using the [ICU Message Editor](/icu-message-editor/).

Source: https://localizely.com/i18n-questions/flutter/how-to-get-a-localization-message-with-a-dynamic-string-key-value-in-flutter/
