File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -302,9 +302,9 @@ class WeatherApiInterceptor implements InterceptorContract {
302302 @override
303303 Future <RequestData > interceptRequest ({required RequestData data}) async {
304304 try {
305- data.params! ['appid' ] = OPEN_WEATHER_API_KEY ;
306- data.params! ['units' ] = 'metric' ;
307- data.headers! [HttpHeaders .contentTypeHeader] = "application/json" ;
305+ data.params['appid' ] = OPEN_WEATHER_API_KEY ;
306+ data.params['units' ] = 'metric' ;
307+ data.headers[HttpHeaders .contentTypeHeader] = "application/json" ;
308308 } catch (e) {
309309 print (e);
310310 }
Original file line number Diff line number Diff line change @@ -7,19 +7,20 @@ import 'package:http_interceptor/utils.dart';
77class RequestData {
88 Method method;
99 String baseUrl;
10- Map <String , String >? headers;
11- Map <String , String >? params;
10+ Map <String , String > headers;
11+ Map <String , String > params;
1212 dynamic ? body;
1313 Encoding ? encoding;
1414
1515 RequestData ({
1616 required this .method,
1717 required this .baseUrl,
18- this . headers,
19- this . params,
18+ Map < String , String > ? headers,
19+ Map < String , String > ? params,
2020 this .body,
2121 this .encoding,
22- });
22+ }) : headers = headers ?? {},
23+ params = params ?? {};
2324
2425 String get url => addParametersToStringUrl (baseUrl, params);
2526
@@ -44,7 +45,7 @@ class RequestData {
4445
4546 Request request = new Request (methodToString (method), reqUrl);
4647
47- if (headers != null ) request.headers.addAll (headers! );
48+ request.headers.addAll (headers);
4849 if (encoding != null ) request.encoding = encoding! ;
4950 if (body != null ) {
5051 if (body is String ) {
You can’t perform that action at this time.
0 commit comments