icuSelect function

String icuSelect(
  1. String value,
  2. Map<String, String> cases, {
  3. required String other,
})

ICU select lite: returns the cases entry whose key equals value, falling back to other for any missing or unknown key.

The common use is gender — icuSelect(g, {'male': '…', 'female': '…'}, other: '…') — but it works for any finite category set (status, role, etc.).

Example:

icuSelect('female', <String, String>{'male': 'He', 'female': 'She'}, other: 'They');
// 'She'

Audited: 2026-06-12 11:26 EDT

Implementation

String icuSelect(String value, Map<String, String> cases, {required String other}) =>
    cases[value] ?? other;