parseStringFromInlineMap function

Map<String, String>? parseStringFromInlineMap(
  1. Object? s,
  2. Pattern delimiterPairs,
  3. Pattern delimiterKeyValue, [
  4. Map<String, String>? def,
])

Parses s as a inline Map<String,String>.

delimiterPairs Delimiter for pairs. delimiterKeyValue Delimiter for keys and values. def Default map if s is invalid.

Implementation

Map<String, String>? parseStringFromInlineMap(
    Object? s, Pattern delimiterPairs, Pattern delimiterKeyValue,
    [Map<String, String>? def]) {
  if (s == null) return def;
  if (s is Map) {
    return s.map((k, v) => MapEntry(parseString(k, '')!, parseString(v, '')!));
  }
  return parseFromInlineMap(s.toString(), delimiterPairs, delimiterKeyValue,
      (e) => parseString(e)!, (e) => parseString(e)!, def);
}