Showing
8 changed files
with
51 additions
and
20 deletions
@@ -110,7 +110,7 @@ class GetConnect extends GetConnectInterface { | @@ -110,7 +110,7 @@ class GetConnect extends GetConnectInterface { | ||
110 | Decoder<T> decoder, | 110 | Decoder<T> decoder, |
111 | }) { | 111 | }) { |
112 | _checkIfDisposed(); | 112 | _checkIfDisposed(); |
113 | - return httpClient.get( | 113 | + return httpClient.get<T>( |
114 | url, | 114 | url, |
115 | headers: headers, | 115 | headers: headers, |
116 | contentType: contentType, | 116 | contentType: contentType, |
@@ -149,7 +149,7 @@ class GetConnect extends GetConnectInterface { | @@ -149,7 +149,7 @@ class GetConnect extends GetConnectInterface { | ||
149 | Decoder<T> decoder, | 149 | Decoder<T> decoder, |
150 | }) { | 150 | }) { |
151 | _checkIfDisposed(); | 151 | _checkIfDisposed(); |
152 | - return httpClient.put( | 152 | + return httpClient.put<T>( |
153 | url, | 153 | url, |
154 | body: body, | 154 | body: body, |
155 | headers: headers, | 155 | headers: headers, |
@@ -170,8 +170,9 @@ class GetConnect extends GetConnectInterface { | @@ -170,8 +170,9 @@ class GetConnect extends GetConnectInterface { | ||
170 | Decoder<T> decoder, | 170 | Decoder<T> decoder, |
171 | }) { | 171 | }) { |
172 | _checkIfDisposed(); | 172 | _checkIfDisposed(); |
173 | - return httpClient.put( | 173 | + return httpClient.request<T>( |
174 | url, | 174 | url, |
175 | + method, | ||
175 | body: body, | 176 | body: body, |
176 | headers: headers, | 177 | headers: headers, |
177 | contentType: contentType, | 178 | contentType: contentType, |
@@ -127,13 +127,14 @@ class GetHttpClient { | @@ -127,13 +127,14 @@ class GetHttpClient { | ||
127 | 127 | ||
128 | final uri = _createUri(url, query); | 128 | final uri = _createUri(url, query); |
129 | 129 | ||
130 | - return Request( | 130 | + return Request<T>( |
131 | method: method, | 131 | method: method, |
132 | url: uri, | 132 | url: uri, |
133 | headers: headers, | 133 | headers: headers, |
134 | bodyBytes: bodyStream, | 134 | bodyBytes: bodyStream, |
135 | followRedirects: followRedirects, | 135 | followRedirects: followRedirects, |
136 | maxRedirects: maxRedirects, | 136 | maxRedirects: maxRedirects, |
137 | + decoder: decoder, | ||
137 | ); | 138 | ); |
138 | } | 139 | } |
139 | 140 | ||
@@ -168,7 +169,7 @@ class GetHttpClient { | @@ -168,7 +169,7 @@ class GetHttpClient { | ||
168 | if (HttpStatus.unauthorized == response.statusCode && | 169 | if (HttpStatus.unauthorized == response.statusCode && |
169 | _modifier.authenticator != null && | 170 | _modifier.authenticator != null && |
170 | requestNumber <= maxAuthRetries) { | 171 | requestNumber <= maxAuthRetries) { |
171 | - return _performRequest( | 172 | + return _performRequest<T>( |
172 | handler, | 173 | handler, |
173 | authenticate: true, | 174 | authenticate: true, |
174 | requestNumber: requestNumber + 1, | 175 | requestNumber: requestNumber + 1, |
@@ -235,7 +236,7 @@ class GetHttpClient { | @@ -235,7 +236,7 @@ class GetHttpClient { | ||
235 | body, | 236 | body, |
236 | 'post', | 237 | 'post', |
237 | query, | 238 | query, |
238 | - decoder, | 239 | + decoder ?? (defaultDecoder as Decoder<T>), |
239 | ); | 240 | ); |
240 | } | 241 | } |
241 | 242 | ||
@@ -247,7 +248,14 @@ class GetHttpClient { | @@ -247,7 +248,14 @@ class GetHttpClient { | ||
247 | @required Map<String, dynamic> query, | 248 | @required Map<String, dynamic> query, |
248 | Decoder<T> decoder, | 249 | Decoder<T> decoder, |
249 | }) { | 250 | }) { |
250 | - return _requestWithBody(url, contentType, body, method, query, decoder); | 251 | + return _requestWithBody<T>( |
252 | + url, | ||
253 | + contentType, | ||
254 | + body, | ||
255 | + method, | ||
256 | + query, | ||
257 | + decoder ?? (defaultDecoder as Decoder<T>), | ||
258 | + ); | ||
251 | } | 259 | } |
252 | 260 | ||
253 | Future<Request<T>> _put<T>( | 261 | Future<Request<T>> _put<T>( |
@@ -257,7 +265,14 @@ class GetHttpClient { | @@ -257,7 +265,14 @@ class GetHttpClient { | ||
257 | @required Map<String, dynamic> query, | 265 | @required Map<String, dynamic> query, |
258 | Decoder<T> decoder, | 266 | Decoder<T> decoder, |
259 | }) { | 267 | }) { |
260 | - return _requestWithBody(url, contentType, body, 'put', query, decoder); | 268 | + return _requestWithBody<T>( |
269 | + url, | ||
270 | + contentType, | ||
271 | + body, | ||
272 | + 'put', | ||
273 | + query, | ||
274 | + decoder ?? (defaultDecoder as Decoder<T>), | ||
275 | + ); | ||
261 | } | 276 | } |
262 | 277 | ||
263 | Request<T> _delete<T>( | 278 | Request<T> _delete<T>( |
@@ -271,7 +286,11 @@ class GetHttpClient { | @@ -271,7 +286,11 @@ class GetHttpClient { | ||
271 | final uri = _createUri(url, query); | 286 | final uri = _createUri(url, query); |
272 | 287 | ||
273 | return Request<T>( | 288 | return Request<T>( |
274 | - method: 'delete', url: uri, headers: headers, decoder: decoder); | 289 | + method: 'delete', |
290 | + url: uri, | ||
291 | + headers: headers, | ||
292 | + decoder: decoder ?? (defaultDecoder as Decoder<T>), | ||
293 | + ); | ||
275 | } | 294 | } |
276 | 295 | ||
277 | Future<Response<T>> post<T>( | 296 | Future<Response<T>> post<T>( |
@@ -312,15 +331,15 @@ class GetHttpClient { | @@ -312,15 +331,15 @@ class GetHttpClient { | ||
312 | Future<Response<T>> request<T>( | 331 | Future<Response<T>> request<T>( |
313 | String url, | 332 | String url, |
314 | String method, { | 333 | String method, { |
315 | - Map<String, dynamic> body, | 334 | + dynamic body, |
316 | String contentType, | 335 | String contentType, |
317 | Map<String, String> headers, | 336 | Map<String, String> headers, |
318 | Map<String, dynamic> query, | 337 | Map<String, dynamic> query, |
319 | Decoder<T> decoder, | 338 | Decoder<T> decoder, |
320 | }) async { | 339 | }) async { |
321 | try { | 340 | try { |
322 | - var response = await _performRequest( | ||
323 | - () => _request( | 341 | + var response = await _performRequest<T>( |
342 | + () => _request<T>( | ||
324 | url, | 343 | url, |
325 | method, | 344 | method, |
326 | contentType: contentType, | 345 | contentType: contentType, |
@@ -353,8 +372,8 @@ class GetHttpClient { | @@ -353,8 +372,8 @@ class GetHttpClient { | ||
353 | Decoder<T> decoder, | 372 | Decoder<T> decoder, |
354 | }) async { | 373 | }) async { |
355 | try { | 374 | try { |
356 | - var response = await _performRequest( | ||
357 | - () => _put( | 375 | + var response = await _performRequest<T>( |
376 | + () => _put<T>( | ||
358 | url, | 377 | url, |
359 | contentType: contentType, | 378 | contentType: contentType, |
360 | query: query, | 379 | query: query, |
@@ -411,7 +430,7 @@ class GetHttpClient { | @@ -411,7 +430,7 @@ class GetHttpClient { | ||
411 | Decoder<T> decoder, | 430 | Decoder<T> decoder, |
412 | }) async { | 431 | }) async { |
413 | try { | 432 | try { |
414 | - var response = await _performRequest( | 433 | + var response = await _performRequest<T>( |
415 | () async => _delete<T>(url, contentType, query, decoder), | 434 | () async => _delete<T>(url, contentType, query, decoder), |
416 | headers: headers, | 435 | headers: headers, |
417 | ); | 436 | ); |
@@ -10,9 +10,13 @@ class FormData { | @@ -10,9 +10,13 @@ class FormData { | ||
10 | FormData(Map<String, dynamic> map) : boundary = _getBoundary() { | 10 | FormData(Map<String, dynamic> map) : boundary = _getBoundary() { |
11 | urlEncode(map, '', false, (key, value) { | 11 | urlEncode(map, '', false, (key, value) { |
12 | if (value == null) return; | 12 | if (value == null) return; |
13 | - (value is MultipartFile) | ||
14 | - ? files.add(MapEntry(key, value)) | ||
15 | - : fields.add(MapEntry(key, value.toString())); | 13 | + if (value is MultipartFile) { |
14 | + files.add(MapEntry(key, value)); | ||
15 | + } else if (value is List<MultipartFile>) { | ||
16 | + files.addAll(value.map((e) => MapEntry(key, e))); | ||
17 | + } else { | ||
18 | + fields.add(MapEntry(key, value.toString())); | ||
19 | + } | ||
16 | return; | 20 | return; |
17 | }); | 21 | }); |
18 | } | 22 | } |
@@ -54,7 +54,7 @@ class Request<T> { | @@ -54,7 +54,7 @@ class Request<T> { | ||
54 | int maxRedirects = 4, | 54 | int maxRedirects = 4, |
55 | FormData files, | 55 | FormData files, |
56 | bool persistentConnection = true, | 56 | bool persistentConnection = true, |
57 | - final Decoder<T> decoder, | 57 | + Decoder<T> decoder, |
58 | }) { | 58 | }) { |
59 | assert(url != null); | 59 | assert(url != null); |
60 | assert(method != null); | 60 | assert(method != null); |
@@ -204,6 +204,7 @@ class GetCupertinoApp extends StatelessWidget { | @@ -204,6 +204,7 @@ class GetCupertinoApp extends StatelessWidget { | ||
204 | settings: RouteSettings(name: name, arguments: null), | 204 | settings: RouteSettings(name: name, arguments: null), |
205 | curve: unknownRoute.curve, | 205 | curve: unknownRoute.curve, |
206 | opaque: unknownRoute.opaque, | 206 | opaque: unknownRoute.opaque, |
207 | + routeName: unknownRoute.name, | ||
207 | customTransition: unknownRoute.customTransition, | 208 | customTransition: unknownRoute.customTransition, |
208 | binding: unknownRoute.binding, | 209 | binding: unknownRoute.binding, |
209 | bindings: unknownRoute.bindings, | 210 | bindings: unknownRoute.bindings, |
@@ -223,6 +224,7 @@ class GetCupertinoApp extends StatelessWidget { | @@ -223,6 +224,7 @@ class GetCupertinoApp extends StatelessWidget { | ||
223 | settings: RouteSettings(name: name, arguments: null), | 224 | settings: RouteSettings(name: name, arguments: null), |
224 | curve: match.route.curve, | 225 | curve: match.route.curve, |
225 | opaque: match.route.opaque, | 226 | opaque: match.route.opaque, |
227 | + routeName: match.route.name, | ||
226 | binding: match.route.binding, | 228 | binding: match.route.binding, |
227 | bindings: match.route.bindings, | 229 | bindings: match.route.bindings, |
228 | transitionDuration: | 230 | transitionDuration: |
@@ -215,6 +215,7 @@ class GetMaterialApp extends StatelessWidget { | @@ -215,6 +215,7 @@ class GetMaterialApp extends StatelessWidget { | ||
215 | settings: RouteSettings(name: name, arguments: null), | 215 | settings: RouteSettings(name: name, arguments: null), |
216 | curve: unknownRoute.curve, | 216 | curve: unknownRoute.curve, |
217 | opaque: unknownRoute.opaque, | 217 | opaque: unknownRoute.opaque, |
218 | + routeName: unknownRoute.name, | ||
218 | customTransition: unknownRoute.customTransition, | 219 | customTransition: unknownRoute.customTransition, |
219 | binding: unknownRoute.binding, | 220 | binding: unknownRoute.binding, |
220 | bindings: unknownRoute.bindings, | 221 | bindings: unknownRoute.bindings, |
@@ -235,6 +236,7 @@ class GetMaterialApp extends StatelessWidget { | @@ -235,6 +236,7 @@ class GetMaterialApp extends StatelessWidget { | ||
235 | curve: match.route.curve, | 236 | curve: match.route.curve, |
236 | opaque: match.route.opaque, | 237 | opaque: match.route.opaque, |
237 | binding: match.route.binding, | 238 | binding: match.route.binding, |
239 | + routeName: match.route.name, | ||
238 | bindings: match.route.bindings, | 240 | bindings: match.route.bindings, |
239 | transitionDuration: | 241 | transitionDuration: |
240 | (match.route.transitionDuration ?? Get.defaultTransitionDuration), | 242 | (match.route.transitionDuration ?? Get.defaultTransitionDuration), |
1 | name: get | 1 | name: get |
2 | description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with GetX. | 2 | description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with GetX. |
3 | -version: 3.21.1 | 3 | +version: 3.21.2 |
4 | homepage: https://github.com/jonataslaw/getx | 4 | homepage: https://github.com/jonataslaw/getx |
5 | 5 | ||
6 | environment: | 6 | environment: |
-
Please register or login to post a comment