decodeQueryGroup static method

Map<String, String> decodeQueryGroup(
  1. String? group
)

Decodes a query group encoded value back to a Map.

Implementation

static Map<String, String> decodeQueryGroup(String? group) {
  if (group == null || group == '{}') return {};

  final params = group.substring(1, group.length - 1).split(',');

  return Map<String, String>.fromEntries(
    params.map(
      (param) {
        final parts = param.split(':');
        final decodedKey = tryDecodeComponent(parts[0]);
        final decodedValue = tryDecodeComponent(parts[1]);

        return MapEntry(decodedKey ?? parts[0], decodedValue ?? parts[1]);
      },
    ),
  );
}