Showing
8 changed files
with
70 additions
and
16 deletions
1 | +## [3.23.0] | ||
2 | +- Add GetResponsive (@SchabanBo) | ||
3 | +- Update tests, fix predicate for offNamedUntil (@vbuberen) | ||
4 | +- Added Urdu Version for Pakistani Developers (@UsamaSarwar) | ||
5 | +- Handle for List field with native datatype on GetConnect(@jasonlaw) | ||
6 | +- Added WillPopScope to defaultDialog (@rakeshlanjewar) | ||
7 | +- Fix optional query params not attach on createUri from GetConnect (@reinaldowebdev) | ||
8 | +- Effective Get.testMode from navigator on tests (@eduardoflorence) | ||
9 | +- Fix Navigator 2.0 on GetMaterialApp and CupertinoMaterialApp (@SchabanBo) | ||
10 | +- Added Middlewares with initial Routes (@SchabanBo) | ||
11 | +- Improve PT-br Docs (@eduardoflorence) | ||
12 | +- Added the allowSelfSigned parameter to GetSocket(@eduardoflorence) | ||
13 | +- Added Indonesian version to Indonesian Developers (@pratamatama) | ||
14 | + | ||
1 | ## [3.22.2] | 15 | ## [3.22.2] |
2 | - Fix overlayEntries is null on Master/Dev branch of Flutter | 16 | - Fix overlayEntries is null on Master/Dev branch of Flutter |
3 | 17 |
@@ -43,12 +43,6 @@ class HttpRequestImpl extends HttpRequestBase { | @@ -43,12 +43,6 @@ class HttpRequestImpl extends HttpRequestBase { | ||
43 | ..contentLength = requestBody.length ?? -1; | 43 | ..contentLength = requestBody.length ?? -1; |
44 | request.headers.forEach(ioRequest.headers.set); | 44 | request.headers.forEach(ioRequest.headers.set); |
45 | 45 | ||
46 | - // var response = await stream.map((s) { | ||
47 | - // received += s.length; | ||
48 | - // print("${(received / total) * 100} %"); | ||
49 | - // return s; | ||
50 | - // }).pipe(ioRequest) as io.HttpClientResponse; | ||
51 | - | ||
52 | var response = await stream.pipe(ioRequest) as io.HttpClientResponse; | 46 | var response = await stream.pipe(ioRequest) as io.HttpClientResponse; |
53 | 47 | ||
54 | var headers = <String, String>{}; | 48 | var headers = <String, String>{}; |
@@ -59,8 +53,6 @@ class HttpRequestImpl extends HttpRequestBase { | @@ -59,8 +53,6 @@ class HttpRequestImpl extends HttpRequestBase { | ||
59 | final bodyBytes = BodyBytesStream(response); | 53 | final bodyBytes = BodyBytesStream(response); |
60 | final stringBody = await bodyBytesToString(bodyBytes, headers); | 54 | final stringBody = await bodyBytesToString(bodyBytes, headers); |
61 | 55 | ||
62 | - // response.headers.contentType.mimeType == 'application/json' | ||
63 | - | ||
64 | final body = bodyDecoded<T>( | 56 | final body = bodyDecoded<T>( |
65 | request, | 57 | request, |
66 | stringBody, | 58 | stringBody, |
1 | +import '../../request/request.dart'; | ||
2 | +import '../../response/response.dart'; | ||
3 | +import '../interface/request_base.dart'; | ||
4 | +import '../utils/body_decoder.dart'; | ||
5 | + | ||
6 | +typedef MockClientHandler = Future<Response> Function(Request request); | ||
7 | + | ||
8 | +class MockClient extends HttpRequestBase { | ||
9 | + /// The handler for than transforms request on response | ||
10 | + final MockClientHandler _handler; | ||
11 | + | ||
12 | + /// Creates a [MockClient] with a handler that receives [Request]s and sends | ||
13 | + /// [Response]s. | ||
14 | + MockClient(this._handler); | ||
15 | + | ||
16 | + @override | ||
17 | + Future<Response<T>> send<T>(Request<T> request) async { | ||
18 | + var requestBody = await request.bodyBytes.toBytes(); | ||
19 | + var bodyBytes = BodyBytesStream.fromBytes(requestBody ?? const []); | ||
20 | + | ||
21 | + var response = await _handler(request); | ||
22 | + | ||
23 | + final stringBody = await bodyBytesToString(bodyBytes, response.headers); | ||
24 | + | ||
25 | + var mimeType = response.headers.containsKey('content-type') | ||
26 | + ? response.headers['content-type'] | ||
27 | + : ''; | ||
28 | + | ||
29 | + final body = bodyDecoded<T>( | ||
30 | + request, | ||
31 | + stringBody, | ||
32 | + mimeType, | ||
33 | + ); | ||
34 | + return Response( | ||
35 | + headers: response.headers, | ||
36 | + request: request, | ||
37 | + statusCode: response.statusCode, | ||
38 | + statusText: response.statusText, | ||
39 | + bodyBytes: bodyBytes, | ||
40 | + body: body, | ||
41 | + bodyString: stringBody, | ||
42 | + ); | ||
43 | + } | ||
44 | + | ||
45 | + @override | ||
46 | + void close() { | ||
47 | + // TODO: implement close | ||
48 | + } | ||
49 | +} |
@@ -8,13 +8,15 @@ T bodyDecoded<T>(Request<T> request, String stringBody, String mimeType) { | @@ -8,13 +8,15 @@ T bodyDecoded<T>(Request<T> request, String stringBody, String mimeType) { | ||
8 | T body; | 8 | T body; |
9 | var bodyToDecode; | 9 | var bodyToDecode; |
10 | 10 | ||
11 | - if (mimeType.contains('application/json')) { | 11 | + if (mimeType != null && mimeType.contains('application/json')) { |
12 | try { | 12 | try { |
13 | bodyToDecode = jsonDecode(stringBody); | 13 | bodyToDecode = jsonDecode(stringBody); |
14 | } on FormatException catch (_) { | 14 | } on FormatException catch (_) { |
15 | Get.log('Cannot decode server response to json'); | 15 | Get.log('Cannot decode server response to json'); |
16 | bodyToDecode = stringBody; | 16 | bodyToDecode = stringBody; |
17 | } | 17 | } |
18 | + } else { | ||
19 | + bodyToDecode = stringBody; | ||
18 | } | 20 | } |
19 | 21 | ||
20 | try { | 22 | try { |
@@ -3,9 +3,7 @@ import 'src/sockets_stub.dart' | @@ -3,9 +3,7 @@ import 'src/sockets_stub.dart' | ||
3 | if (dart.library.io) 'src/sockets_io.dart'; | 3 | if (dart.library.io) 'src/sockets_io.dart'; |
4 | 4 | ||
5 | class GetSocket extends BaseWebSocket { | 5 | class GetSocket extends BaseWebSocket { |
6 | - GetSocket( | ||
7 | - String url, { | ||
8 | - Duration ping = const Duration(seconds: 5), | ||
9 | - bool allowSelfSigned = true | ||
10 | - }) : super(url, ping: ping, allowSelfSigned: allowSelfSigned); | 6 | + GetSocket(String url, |
7 | + {Duration ping = const Duration(seconds: 5), bool allowSelfSigned = true}) | ||
8 | + : super(url, ping: ping, allowSelfSigned: allowSelfSigned); | ||
11 | } | 9 | } |
@@ -51,5 +51,4 @@ class BaseWebSocket { | @@ -51,5 +51,4 @@ class BaseWebSocket { | ||
51 | void emit(String event, dynamic data) { | 51 | void emit(String event, dynamic data) { |
52 | throw 'To use sockets you need dart:io or dart:html'; | 52 | throw 'To use sockets you need dart:io or dart:html'; |
53 | } | 53 | } |
54 | - | ||
55 | } | 54 | } |
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.22.2 | 3 | +version: 3.23.0 |
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