@@ -148,12 +148,13 @@ class PostgrestBuilder<T, S, R> implements Future<T> {
148148 // X-Retry-Count, etc.).
149149 final execHeaders = {..._headers};
150150
151- if (_count != null ) {
151+ final count = _count;
152+ if (count != null ) {
152153 if (execHeaders['Prefer' ] != null ) {
153154 final oldPreferHeader = execHeaders['Prefer' ];
154- execHeaders['Prefer' ] = '$oldPreferHeader ,count=${_count .name }' ;
155+ execHeaders['Prefer' ] = '$oldPreferHeader ,count=${count .name }' ;
155156 } else {
156- execHeaders['Prefer' ] = 'count=${_count .name }' ;
157+ execHeaders['Prefer' ] = 'count=${count .name }' ;
157158 }
158159 }
159160
@@ -173,12 +174,13 @@ class PostgrestBuilder<T, S, R> implements Future<T> {
173174 );
174175 }
175176
176- if (_schema == null ) {
177+ final schema = _schema;
178+ if (schema == null ) {
177179 // skip
178180 } else if (method == _HttpMethod .get || method == _HttpMethod .head) {
179- execHeaders['Accept-Profile' ] = _schema ;
181+ execHeaders['Accept-Profile' ] = schema ;
180182 } else {
181- execHeaders['Content-Profile' ] = _schema ;
183+ execHeaders['Content-Profile' ] = schema ;
182184 }
183185 if (method != _HttpMethod .get && method != _HttpMethod .head) {
184186 execHeaders['Content-Type' ] = 'application/json' ;
@@ -284,8 +286,9 @@ class PostgrestBuilder<T, S, R> implements Future<T> {
284286 body = response.body;
285287 } else {
286288 try {
287- if ((response.contentLength ?? 0 ) > 10000 && _isolate != null ) {
288- body = await _isolate.decode (response.body);
289+ final isolate = _isolate;
290+ if ((response.contentLength ?? 0 ) > 10000 && isolate != null ) {
291+ body = await isolate.decode (response.body);
289292 } else {
290293 body = jsonDecode (response.body);
291294 }
@@ -339,16 +342,17 @@ class PostgrestBuilder<T, S, R> implements Future<T> {
339342 }
340343 body as R ;
341344
342- if (_converter != null ) {
343- converted = _converter (body);
345+ final converter = _converter;
346+ if (converter != null ) {
347+ converted = converter (body);
344348 } else {
345349 converted = body as S ;
346350 }
347351
348- if (_count != null && method != _HttpMethod .head) {
352+ if (count != null && method != _HttpMethod .head) {
349353 return PostgrestResponse <S >(
350354 data: converted,
351- count: count! ,
355+ count: count,
352356 ) as T ;
353357 } else {
354358 return converted as T ;
@@ -400,17 +404,18 @@ class PostgrestBuilder<T, S, R> implements Future<T> {
400404 ) {
401405 if (error.details is String &&
402406 error.details.toString ().contains ('Results contain 0 rows' )) {
407+ final converter = _converter;
403408 if (_count != null &&
404409 response.request! .method != _HttpMethod .head.value) {
405- if (_converter != null ) {
406- return PostgrestResponse <S >(data: _converter (null as R ), count: 0 )
410+ if (converter != null ) {
411+ return PostgrestResponse <S >(data: converter (null as R ), count: 0 )
407412 as T ;
408413 } else {
409414 return null as T ;
410415 }
411416 } else {
412- if (_converter != null ) {
413- return _converter (null as R ) as T ;
417+ if (converter != null ) {
418+ return converter (null as R ) as T ;
414419 } else {
415420 return null as T ;
416421 }
0 commit comments