From 9485e84720e6b0a2e2ec7aa5ba1175c7a78687b6 Mon Sep 17 00:00:00 2001 From: Vinzent Date: Mon, 18 Sep 2023 19:33:51 +0200 Subject: [PATCH] fix: don't try to decode an empty body --- packages/postgrest/lib/src/postgrest_builder.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/postgrest/lib/src/postgrest_builder.dart b/packages/postgrest/lib/src/postgrest_builder.dart index 892d47cf..2c8057ac 100644 --- a/packages/postgrest/lib/src/postgrest_builder.dart +++ b/packages/postgrest/lib/src/postgrest_builder.dart @@ -212,7 +212,9 @@ class PostgrestBuilder implements Future { int? count; if (response.request!.method != METHOD_HEAD) { - if (response.request!.headers['Accept'] == 'text/csv') { + if (response.bodyBytes.isEmpty) { + body = null; + } else if (response.request!.headers['Accept'] == 'text/csv') { body = response.body; } else { try {