parse static method
Parses the given query string into a Map.
Implementation
static Map parse(String query) {
RegExp search = RegExp('([^&=]+)=?([^&]*)');
Map result = Map();
// Get rid off the beginning ? in query strings.
if (query.startsWith('?')) query = query.substring(1);
// A custom decoder.
decode(String s) => Uri.decodeComponent(s.replaceAll('+', ' '));
// Go through all the matches and build the result map.
for (Match match in search.allMatches(query)) {
result[decode(match.group(1) ?? "")] = decode(match.group(2) ?? "");
}
return result;
}