我想将map
作为标头参数传递。
Future<HomeResponse> getHomeResponse(
String url, Map<String, String> headers) async {
http.Response response = await http.get(url,
headers: {"token": headers["token"], "name": headers["name"]});
final responseBody = json.decode(response.body);
final statusCode = response.statusCode;
if (statusCode != 200 || responseBody == null) {
throw new ServerExceptionHandler(
"An error ocurred : [Status Code : $statusCode]");
}
return new HomeResponse.fromJson(responseBody);
}