Allow any Map<String, dynamic> as body, not just Map<String, String>

This commit is contained in:
Tobe O 2019-04-20 11:23:06 -04:00
parent 6c9379698a
commit 47ccb07218
2 changed files with 4 additions and 2 deletions

View file

@ -1,5 +1,6 @@
# 2.0.2
* `_join` previously discarded quer parameters, etc.
* Allow any `Map<String, dynamic>` as body, not just `Map<String, String>`.
# 2.0.1
* Change `BaseAngelClient` constructor to accept `dynamic` instead of `String` for `baseUrl.

View file

@ -138,8 +138,9 @@ abstract class BaseAngelClient extends Angel {
request.body = body;
} else if (body is List<int>) {
request.bodyBytes = new List<int>.from(body);
} else if (body is Map<String, String>) {
request.bodyFields = new Map<String, String>.from(body);
} else if (body is Map<String, dynamic>) {
request.bodyFields =
body.map((k, v) => MapEntry(k, v is String ? v : v.toString()));
} else {
throw new ArgumentError.value(body, 'body',
'must be a String, List<int>, or Map<String, String>.');