parseQueryString function
Parse query string to map (and back). Roadmap #168.
Implementation
Map<String, String> parseQueryString(String query) {
final Map<String, String> out = <String, String>{};
if (query.isEmpty) return out;
for (final String pair in query.split('&')) {
final int eq = pair.indexOf('=');
if (eq != -1) {
out[Uri.decodeComponent(pair.replaceRange(eq, pair.length, ''))] = Uri.decodeComponent(
pair.replaceRange(0, eq + 1, ''),
);
} else if (pair.isNotEmpty) {
out[Uri.decodeComponent(pair)] = '';
}
}
return out;
}