getMessage method

Message getMessage(
  1. dynamic message, [
  2. bool isTopLevel = false
])

Implementation

Message getMessage(dynamic message, [bool isTopLevel = false]) {
  if (message is List) {
    final typeOrId = message[0];
    int start;
    String? id;
    if (isTopLevel && preamble.hasIds) {
      start = 2;
      id = message[1] as String;
    } else {
      start = 1;
    }
    if (typeOrId == PluralMessage.type) {
      return _forPlural(message, start, id);
    } else if (typeOrId == SelectMessage.type) {
      return _forSelect(message, start, id);
    } else if (typeOrId == CombinedMessage.type) {
      return _forCombined(message, start, id);
    } else if (typeOrId is String) {
      return _forString(message, start - 1, typeOrId);
    }
  } else if (message is String) {
    return StringMessage(message);
  }
  throw ArgumentError();
}