Skip to content

Commit 26e6075

Browse files
committed
Properly handle null field values when encoding requests. See: #75
1 parent e9dbebd commit 26e6075

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/src/utils.dart

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ Map/*<K, V>*/ updateMap/*<K, V>*/(
3030
/// mapToQuery({"foo": "bar", "baz": "bang"});
3131
/// //=> "foo=bar&baz=bang"
3232
String mapToQuery(Map<String, String> map, {Encoding encoding}) {
33+
map.keys
34+
.where((k) => (map[k] == null)).toList() // -- keys for null elements
35+
.forEach(map.remove);
36+
3337
var pairs = <List<String>>[];
3438
map.forEach((key, value) =>
3539
pairs.add([Uri.encodeQueryComponent(key, encoding: encoding),

0 commit comments

Comments
 (0)