From e6cfc10b1bb2104ddd46b9f03c07430475beebbd Mon Sep 17 00:00:00 2001 From: Orlando Eduardo Pereira <37966182+OrlandoEduardo101@users.noreply.github.com> Date: Tue, 4 Jun 2024 22:50:51 -0300 Subject: [PATCH 1/2] #34 - return empty json when bufferString is empty / update dependencies --- example/pubspec.yaml | 5 +++-- lib/src/external/universal_http_client.dart | 4 ++++ pubspec.yaml | 6 +++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 322c741..613c3fc 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -35,13 +35,14 @@ dependencies: # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 dartz: ^0.10.1 - uno: ^1.0.1+3 - mocktail: ^0.3.0 + uno: + path: ../ mobx_triple: ^1.1.3+1 flutter_modular: ^5.0.3 flutter_triple: ^1.2.7+4 dev_dependencies: + mocktail: ^1.0.3 flutter_test: sdk: flutter integration_test: diff --git a/lib/src/external/universal_http_client.dart b/lib/src/external/universal_http_client.dart index f8ebee1..a9492b7 100644 --- a/lib/src/external/universal_http_client.dart +++ b/lib/src/external/universal_http_client.dart @@ -150,6 +150,10 @@ class UniversalHttpClient implements HttpDatasource { buffer.write(item); } + if (buffer.toString().isEmpty) { + return {}; + } + return jsonDecode(buffer.toString()); } on FormatException catch (e, s) { throw UnoError( diff --git a/pubspec.yaml b/pubspec.yaml index 64d5c6c..752a0ec 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,11 +10,11 @@ dependencies: universal_io: '>=2.2.0 <3.0.0' characters: '>=1.2.1 <2.0.0' meta: '>=1.8.0 <2.0.0' - mime_type: ^1.0.0 + mime_type: '>=1.0.0 <2.0.0' path: '>=1.8.2 <2.0.0' - file: '>=6.1.4 <7.0.0' + file: '>=6.1.4 <8.0.0' dev_dependencies: - mocktail: ^0.3.0 + mocktail: ^1.0.3 flutterando_analysis: ^0.0.2 test: '>=1.10.0 <2.0.0' From a8f915a65317f71006b3239e10807f0dfc1e10d0 Mon Sep 17 00:00:00 2001 From: Orlando Eduardo Pereira <37966182+OrlandoEduardo101@users.noreply.github.com> Date: Tue, 4 Jun 2024 22:59:01 -0300 Subject: [PATCH 2/2] #34 - fix check in if --- lib/src/external/universal_http_client.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/external/universal_http_client.dart b/lib/src/external/universal_http_client.dart index a9492b7..09cf8a9 100644 --- a/lib/src/external/universal_http_client.dart +++ b/lib/src/external/universal_http_client.dart @@ -150,7 +150,7 @@ class UniversalHttpClient implements HttpDatasource { buffer.write(item); } - if (buffer.toString().isEmpty) { + if (buffer.toString().isEmpty && responseType == ResponseType.json) { return {}; }