stringList function

List<String> stringList(
  1. Map<String, dynamic> json,
  2. String key
)

Reads a flat list of strings at key, dropping any non-string element. Missing or wrong-shaped reads as an empty list — the same tolerant widening as opt, for a key that is ORDERING metadata rather than a source of truth (panel.locales): a malformed value degrading to "no preferred order" is harmless, so it is never worth a thrown exception.

Implementation

List<String> stringList(Map<String, dynamic> json, String key) {
  final value = json[key];
  if (value is! List) return const [];
  return [
    for (final item in value)
      if (item is String) item,
  ];
}