Dart Http Client returns truncated response, truncation varies slightly when I print to console











up vote
0
down vote

favorite












I am trying to read a JSON Response and build UI with Flutter's FutureBuilder but I am unable to get the entire JSON response on the client. When I try to print the response in two different print statements, the contents among them vary by a tiny bit. Notice how the console print output below differs for My Posts API Response and My Posts Json Response String.



Could someone explain this behaviour and how to implement a proper listen till the complete JSON Array is received at the client's end?



Expected API Response -



[{"_id":"5bd11c9b8a9fc0a744d1bebc","postId":1,"postUserId":1,"postDescription":"First Post with 2 Photos","postLongDescription":"First Post with 2 Photos","postDateTime":"2018-07-27T10:50:42.389Z","postLocationId":1,"postHasMedia":true,"postActive":true,"postLikesCount":3,"postCommentsCount":1},{"_id":"5bd11c9b8a9fc0a744d1bebd","postId":2,"postUserId":2,"postDescription":"Second Post with 1 Video","postLongDescription":"Second Post with 1 Video","postDateTime":"2018-07-27T11:02:00.389Z","postLocationId":2,"postHasMedia":true,"postActive":true,"postLikesCount":12,"postCommentsCount":2},{"_id":"5bd11c9b8a9fc0a744d1bebe","postId":3,"postUserId":2,"postDescription":"Third Post with No Video","postLongDescription":"Third Post with No Video","postDateTime":"2018-07-27T11:12:34.389Z","postLocationId":3,"postHasMedia":false,"postActive":true,"postLikesCount":9,"postCommentsCount":0},{"_id":"5bd11c9b8a9fc0a744d1bebf","postId":4,"postUserId":3,"postDescription":"Fourth Post with 1 Photo but Disabled","postLongDescription":"Fourth Post with 1 Photo but Disabled","postDateTime":"2018-07-27T11:12:34.389Z","postLocationId":2,"postHasMedia":true,"postActive":false,"postLikesCount":4,"postCommentsCount":0}]


Flutter Bloc Code -



import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:MyApp/models/post_model.dart';
import 'package:http/http.dart' as http;

enum storyTypes {
timeline,
myposts
}

class PostsBloc {

Future<PostModel> getPosts(storyTypes storyType) async {
if (storyType == storyTypes.myposts) {
final String url = "http://127.0.0.1:8081/posts/all";
return await http.get(url).then((getMyPostsApiResponse) {
if (getMyPostsApiResponse.statusCode != 200) {
throw Exception("Error with http over network");
}
else {
if (getMyPostsApiResponse.statusCode == 200) {
print('My Posts API Response - ' + getMyPostsApiResponse.body);
print('My Posts Json Response String - ' + json.decode(getMyPostsApiResponse.body).toString());
return PostModel.fromJson(json.decode(getMyPostsApiResponse.body));
}
else {
throw Exception('Failed to load post');
}
}
});
}
}


Flutter Console Output -



I/flutter (32316): My Posts API Response - [{"_id":"5bd11c9b8a9fc0a744d1bebc","postId":1,"postUserId":1,"postDescription":"First Post with 2 Photos","postLongDescription":"First Post with 2 Photos","postDateTime":"2018-07-27T10:50:42.389Z","postLocationId":1,"postHasMedia":true,"postActive":true,"postLikesCount":3,"postCommentsCount":1},{"_id":"5bd11c9b8a9fc0a744d1bebd","postId":2,"postUserId":2,"postDescription":"Second Post with 1 Video","postLongDescription":"Second Post with 1 Video","postDateTime":"2018-07-27T11:02:00.389Z","postLocationId":2,"postHasMedia":true,"postActive":true,"postLikesCount":12,"postCommentsCount":2},{"_id":"5bd11c9b8a9fc0a744d1bebe","postId":3,"postUserId":2,"postDescription":"Third Post with No Video","postLongDescription":"Third Post with No Video","postDateTime":"2018-07-27T11:12:34.389Z","postLocationId":3,"postHasMedia":false,"postActive":true,"postLikesCount":9,"postCommentsCount":0},{"_id":"5bd11c9b8a9fc0a744d1bebf","postId":4,"postUserId":3,"postDescription":"Fourth Post with 1 Photo but Dis    
I/flutter (32316): My Posts Json Response String - [{_id: 5bd11c9b8a9fc0a744d1bebc, postId: 1, postUserId: 1, postDescription: First Post with 2 Photos, postLongDescription: First Post with 2 Photos, postDateTime: 2018-07-27T10:50:42.389Z, postLocationId: 1, postHasMedia: true, postActive: true, postLikesCount: 3, postCommentsCount: 1}, {_id: 5bd11c9b8a9fc0a744d1bebd, postId: 2, postUserId: 2, postDescription: Second Post with 1 Video, postLongDescription: Second Post with 1 Video, postDateTime: 2018-07-27T11:02:00.389Z, postLocationId: 2, postHasMedia: true, postActive: true, postLikesCount: 12, postCommentsCount: 2}, {_id: 5bd11c9b8a9fc0a744d1bebe, postId: 3, postUserId: 2, postDescription: Third Post with No Video, postLongDescription: Third Post with No Video, postDateTime: 2018-07-27T11:12:34.389Z, postLocationId: 3, postHasMedia: false, postActive: true, postLikesCount: 9, postCommentsCount: 0}, {_id: 5bd11c9b8a9fc0a744d1bebf, postId: 4, postUserId: 3, postDescription: Fourth Post with 1 Photo but Disabled, postLongDescr









share|improve this question


























    up vote
    0
    down vote

    favorite












    I am trying to read a JSON Response and build UI with Flutter's FutureBuilder but I am unable to get the entire JSON response on the client. When I try to print the response in two different print statements, the contents among them vary by a tiny bit. Notice how the console print output below differs for My Posts API Response and My Posts Json Response String.



    Could someone explain this behaviour and how to implement a proper listen till the complete JSON Array is received at the client's end?



    Expected API Response -



    [{"_id":"5bd11c9b8a9fc0a744d1bebc","postId":1,"postUserId":1,"postDescription":"First Post with 2 Photos","postLongDescription":"First Post with 2 Photos","postDateTime":"2018-07-27T10:50:42.389Z","postLocationId":1,"postHasMedia":true,"postActive":true,"postLikesCount":3,"postCommentsCount":1},{"_id":"5bd11c9b8a9fc0a744d1bebd","postId":2,"postUserId":2,"postDescription":"Second Post with 1 Video","postLongDescription":"Second Post with 1 Video","postDateTime":"2018-07-27T11:02:00.389Z","postLocationId":2,"postHasMedia":true,"postActive":true,"postLikesCount":12,"postCommentsCount":2},{"_id":"5bd11c9b8a9fc0a744d1bebe","postId":3,"postUserId":2,"postDescription":"Third Post with No Video","postLongDescription":"Third Post with No Video","postDateTime":"2018-07-27T11:12:34.389Z","postLocationId":3,"postHasMedia":false,"postActive":true,"postLikesCount":9,"postCommentsCount":0},{"_id":"5bd11c9b8a9fc0a744d1bebf","postId":4,"postUserId":3,"postDescription":"Fourth Post with 1 Photo but Disabled","postLongDescription":"Fourth Post with 1 Photo but Disabled","postDateTime":"2018-07-27T11:12:34.389Z","postLocationId":2,"postHasMedia":true,"postActive":false,"postLikesCount":4,"postCommentsCount":0}]


    Flutter Bloc Code -



    import 'dart:async';
    import 'dart:convert';
    import 'dart:io';
    import 'package:MyApp/models/post_model.dart';
    import 'package:http/http.dart' as http;

    enum storyTypes {
    timeline,
    myposts
    }

    class PostsBloc {

    Future<PostModel> getPosts(storyTypes storyType) async {
    if (storyType == storyTypes.myposts) {
    final String url = "http://127.0.0.1:8081/posts/all";
    return await http.get(url).then((getMyPostsApiResponse) {
    if (getMyPostsApiResponse.statusCode != 200) {
    throw Exception("Error with http over network");
    }
    else {
    if (getMyPostsApiResponse.statusCode == 200) {
    print('My Posts API Response - ' + getMyPostsApiResponse.body);
    print('My Posts Json Response String - ' + json.decode(getMyPostsApiResponse.body).toString());
    return PostModel.fromJson(json.decode(getMyPostsApiResponse.body));
    }
    else {
    throw Exception('Failed to load post');
    }
    }
    });
    }
    }


    Flutter Console Output -



    I/flutter (32316): My Posts API Response - [{"_id":"5bd11c9b8a9fc0a744d1bebc","postId":1,"postUserId":1,"postDescription":"First Post with 2 Photos","postLongDescription":"First Post with 2 Photos","postDateTime":"2018-07-27T10:50:42.389Z","postLocationId":1,"postHasMedia":true,"postActive":true,"postLikesCount":3,"postCommentsCount":1},{"_id":"5bd11c9b8a9fc0a744d1bebd","postId":2,"postUserId":2,"postDescription":"Second Post with 1 Video","postLongDescription":"Second Post with 1 Video","postDateTime":"2018-07-27T11:02:00.389Z","postLocationId":2,"postHasMedia":true,"postActive":true,"postLikesCount":12,"postCommentsCount":2},{"_id":"5bd11c9b8a9fc0a744d1bebe","postId":3,"postUserId":2,"postDescription":"Third Post with No Video","postLongDescription":"Third Post with No Video","postDateTime":"2018-07-27T11:12:34.389Z","postLocationId":3,"postHasMedia":false,"postActive":true,"postLikesCount":9,"postCommentsCount":0},{"_id":"5bd11c9b8a9fc0a744d1bebf","postId":4,"postUserId":3,"postDescription":"Fourth Post with 1 Photo but Dis    
    I/flutter (32316): My Posts Json Response String - [{_id: 5bd11c9b8a9fc0a744d1bebc, postId: 1, postUserId: 1, postDescription: First Post with 2 Photos, postLongDescription: First Post with 2 Photos, postDateTime: 2018-07-27T10:50:42.389Z, postLocationId: 1, postHasMedia: true, postActive: true, postLikesCount: 3, postCommentsCount: 1}, {_id: 5bd11c9b8a9fc0a744d1bebd, postId: 2, postUserId: 2, postDescription: Second Post with 1 Video, postLongDescription: Second Post with 1 Video, postDateTime: 2018-07-27T11:02:00.389Z, postLocationId: 2, postHasMedia: true, postActive: true, postLikesCount: 12, postCommentsCount: 2}, {_id: 5bd11c9b8a9fc0a744d1bebe, postId: 3, postUserId: 2, postDescription: Third Post with No Video, postLongDescription: Third Post with No Video, postDateTime: 2018-07-27T11:12:34.389Z, postLocationId: 3, postHasMedia: false, postActive: true, postLikesCount: 9, postCommentsCount: 0}, {_id: 5bd11c9b8a9fc0a744d1bebf, postId: 4, postUserId: 3, postDescription: Fourth Post with 1 Photo but Disabled, postLongDescr









    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am trying to read a JSON Response and build UI with Flutter's FutureBuilder but I am unable to get the entire JSON response on the client. When I try to print the response in two different print statements, the contents among them vary by a tiny bit. Notice how the console print output below differs for My Posts API Response and My Posts Json Response String.



      Could someone explain this behaviour and how to implement a proper listen till the complete JSON Array is received at the client's end?



      Expected API Response -



      [{"_id":"5bd11c9b8a9fc0a744d1bebc","postId":1,"postUserId":1,"postDescription":"First Post with 2 Photos","postLongDescription":"First Post with 2 Photos","postDateTime":"2018-07-27T10:50:42.389Z","postLocationId":1,"postHasMedia":true,"postActive":true,"postLikesCount":3,"postCommentsCount":1},{"_id":"5bd11c9b8a9fc0a744d1bebd","postId":2,"postUserId":2,"postDescription":"Second Post with 1 Video","postLongDescription":"Second Post with 1 Video","postDateTime":"2018-07-27T11:02:00.389Z","postLocationId":2,"postHasMedia":true,"postActive":true,"postLikesCount":12,"postCommentsCount":2},{"_id":"5bd11c9b8a9fc0a744d1bebe","postId":3,"postUserId":2,"postDescription":"Third Post with No Video","postLongDescription":"Third Post with No Video","postDateTime":"2018-07-27T11:12:34.389Z","postLocationId":3,"postHasMedia":false,"postActive":true,"postLikesCount":9,"postCommentsCount":0},{"_id":"5bd11c9b8a9fc0a744d1bebf","postId":4,"postUserId":3,"postDescription":"Fourth Post with 1 Photo but Disabled","postLongDescription":"Fourth Post with 1 Photo but Disabled","postDateTime":"2018-07-27T11:12:34.389Z","postLocationId":2,"postHasMedia":true,"postActive":false,"postLikesCount":4,"postCommentsCount":0}]


      Flutter Bloc Code -



      import 'dart:async';
      import 'dart:convert';
      import 'dart:io';
      import 'package:MyApp/models/post_model.dart';
      import 'package:http/http.dart' as http;

      enum storyTypes {
      timeline,
      myposts
      }

      class PostsBloc {

      Future<PostModel> getPosts(storyTypes storyType) async {
      if (storyType == storyTypes.myposts) {
      final String url = "http://127.0.0.1:8081/posts/all";
      return await http.get(url).then((getMyPostsApiResponse) {
      if (getMyPostsApiResponse.statusCode != 200) {
      throw Exception("Error with http over network");
      }
      else {
      if (getMyPostsApiResponse.statusCode == 200) {
      print('My Posts API Response - ' + getMyPostsApiResponse.body);
      print('My Posts Json Response String - ' + json.decode(getMyPostsApiResponse.body).toString());
      return PostModel.fromJson(json.decode(getMyPostsApiResponse.body));
      }
      else {
      throw Exception('Failed to load post');
      }
      }
      });
      }
      }


      Flutter Console Output -



      I/flutter (32316): My Posts API Response - [{"_id":"5bd11c9b8a9fc0a744d1bebc","postId":1,"postUserId":1,"postDescription":"First Post with 2 Photos","postLongDescription":"First Post with 2 Photos","postDateTime":"2018-07-27T10:50:42.389Z","postLocationId":1,"postHasMedia":true,"postActive":true,"postLikesCount":3,"postCommentsCount":1},{"_id":"5bd11c9b8a9fc0a744d1bebd","postId":2,"postUserId":2,"postDescription":"Second Post with 1 Video","postLongDescription":"Second Post with 1 Video","postDateTime":"2018-07-27T11:02:00.389Z","postLocationId":2,"postHasMedia":true,"postActive":true,"postLikesCount":12,"postCommentsCount":2},{"_id":"5bd11c9b8a9fc0a744d1bebe","postId":3,"postUserId":2,"postDescription":"Third Post with No Video","postLongDescription":"Third Post with No Video","postDateTime":"2018-07-27T11:12:34.389Z","postLocationId":3,"postHasMedia":false,"postActive":true,"postLikesCount":9,"postCommentsCount":0},{"_id":"5bd11c9b8a9fc0a744d1bebf","postId":4,"postUserId":3,"postDescription":"Fourth Post with 1 Photo but Dis    
      I/flutter (32316): My Posts Json Response String - [{_id: 5bd11c9b8a9fc0a744d1bebc, postId: 1, postUserId: 1, postDescription: First Post with 2 Photos, postLongDescription: First Post with 2 Photos, postDateTime: 2018-07-27T10:50:42.389Z, postLocationId: 1, postHasMedia: true, postActive: true, postLikesCount: 3, postCommentsCount: 1}, {_id: 5bd11c9b8a9fc0a744d1bebd, postId: 2, postUserId: 2, postDescription: Second Post with 1 Video, postLongDescription: Second Post with 1 Video, postDateTime: 2018-07-27T11:02:00.389Z, postLocationId: 2, postHasMedia: true, postActive: true, postLikesCount: 12, postCommentsCount: 2}, {_id: 5bd11c9b8a9fc0a744d1bebe, postId: 3, postUserId: 2, postDescription: Third Post with No Video, postLongDescription: Third Post with No Video, postDateTime: 2018-07-27T11:12:34.389Z, postLocationId: 3, postHasMedia: false, postActive: true, postLikesCount: 9, postCommentsCount: 0}, {_id: 5bd11c9b8a9fc0a744d1bebf, postId: 4, postUserId: 3, postDescription: Fourth Post with 1 Photo but Disabled, postLongDescr









      share|improve this question













      I am trying to read a JSON Response and build UI with Flutter's FutureBuilder but I am unable to get the entire JSON response on the client. When I try to print the response in two different print statements, the contents among them vary by a tiny bit. Notice how the console print output below differs for My Posts API Response and My Posts Json Response String.



      Could someone explain this behaviour and how to implement a proper listen till the complete JSON Array is received at the client's end?



      Expected API Response -



      [{"_id":"5bd11c9b8a9fc0a744d1bebc","postId":1,"postUserId":1,"postDescription":"First Post with 2 Photos","postLongDescription":"First Post with 2 Photos","postDateTime":"2018-07-27T10:50:42.389Z","postLocationId":1,"postHasMedia":true,"postActive":true,"postLikesCount":3,"postCommentsCount":1},{"_id":"5bd11c9b8a9fc0a744d1bebd","postId":2,"postUserId":2,"postDescription":"Second Post with 1 Video","postLongDescription":"Second Post with 1 Video","postDateTime":"2018-07-27T11:02:00.389Z","postLocationId":2,"postHasMedia":true,"postActive":true,"postLikesCount":12,"postCommentsCount":2},{"_id":"5bd11c9b8a9fc0a744d1bebe","postId":3,"postUserId":2,"postDescription":"Third Post with No Video","postLongDescription":"Third Post with No Video","postDateTime":"2018-07-27T11:12:34.389Z","postLocationId":3,"postHasMedia":false,"postActive":true,"postLikesCount":9,"postCommentsCount":0},{"_id":"5bd11c9b8a9fc0a744d1bebf","postId":4,"postUserId":3,"postDescription":"Fourth Post with 1 Photo but Disabled","postLongDescription":"Fourth Post with 1 Photo but Disabled","postDateTime":"2018-07-27T11:12:34.389Z","postLocationId":2,"postHasMedia":true,"postActive":false,"postLikesCount":4,"postCommentsCount":0}]


      Flutter Bloc Code -



      import 'dart:async';
      import 'dart:convert';
      import 'dart:io';
      import 'package:MyApp/models/post_model.dart';
      import 'package:http/http.dart' as http;

      enum storyTypes {
      timeline,
      myposts
      }

      class PostsBloc {

      Future<PostModel> getPosts(storyTypes storyType) async {
      if (storyType == storyTypes.myposts) {
      final String url = "http://127.0.0.1:8081/posts/all";
      return await http.get(url).then((getMyPostsApiResponse) {
      if (getMyPostsApiResponse.statusCode != 200) {
      throw Exception("Error with http over network");
      }
      else {
      if (getMyPostsApiResponse.statusCode == 200) {
      print('My Posts API Response - ' + getMyPostsApiResponse.body);
      print('My Posts Json Response String - ' + json.decode(getMyPostsApiResponse.body).toString());
      return PostModel.fromJson(json.decode(getMyPostsApiResponse.body));
      }
      else {
      throw Exception('Failed to load post');
      }
      }
      });
      }
      }


      Flutter Console Output -



      I/flutter (32316): My Posts API Response - [{"_id":"5bd11c9b8a9fc0a744d1bebc","postId":1,"postUserId":1,"postDescription":"First Post with 2 Photos","postLongDescription":"First Post with 2 Photos","postDateTime":"2018-07-27T10:50:42.389Z","postLocationId":1,"postHasMedia":true,"postActive":true,"postLikesCount":3,"postCommentsCount":1},{"_id":"5bd11c9b8a9fc0a744d1bebd","postId":2,"postUserId":2,"postDescription":"Second Post with 1 Video","postLongDescription":"Second Post with 1 Video","postDateTime":"2018-07-27T11:02:00.389Z","postLocationId":2,"postHasMedia":true,"postActive":true,"postLikesCount":12,"postCommentsCount":2},{"_id":"5bd11c9b8a9fc0a744d1bebe","postId":3,"postUserId":2,"postDescription":"Third Post with No Video","postLongDescription":"Third Post with No Video","postDateTime":"2018-07-27T11:12:34.389Z","postLocationId":3,"postHasMedia":false,"postActive":true,"postLikesCount":9,"postCommentsCount":0},{"_id":"5bd11c9b8a9fc0a744d1bebf","postId":4,"postUserId":3,"postDescription":"Fourth Post with 1 Photo but Dis    
      I/flutter (32316): My Posts Json Response String - [{_id: 5bd11c9b8a9fc0a744d1bebc, postId: 1, postUserId: 1, postDescription: First Post with 2 Photos, postLongDescription: First Post with 2 Photos, postDateTime: 2018-07-27T10:50:42.389Z, postLocationId: 1, postHasMedia: true, postActive: true, postLikesCount: 3, postCommentsCount: 1}, {_id: 5bd11c9b8a9fc0a744d1bebd, postId: 2, postUserId: 2, postDescription: Second Post with 1 Video, postLongDescription: Second Post with 1 Video, postDateTime: 2018-07-27T11:02:00.389Z, postLocationId: 2, postHasMedia: true, postActive: true, postLikesCount: 12, postCommentsCount: 2}, {_id: 5bd11c9b8a9fc0a744d1bebe, postId: 3, postUserId: 2, postDescription: Third Post with No Video, postLongDescription: Third Post with No Video, postDateTime: 2018-07-27T11:12:34.389Z, postLocationId: 3, postHasMedia: false, postActive: true, postLikesCount: 9, postCommentsCount: 0}, {_id: 5bd11c9b8a9fc0a744d1bebf, postId: 4, postUserId: 3, postDescription: Fourth Post with 1 Photo but Disabled, postLongDescr






      json http dart flutter






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 at 18:15









      Gdcrocx

      1217




      1217
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote













          That's just the console truncating after so many characters.



          Notice that you are printing two different things:



          getMyPostsApiResponse.body is the json received from the server.



          json.decode(getMyPostsApiResponse.body).toString() is the decoded List's toString (which excludes the quote marks, which is why the lengths of the strings are different)






          share|improve this answer





















          • You have a point on the missing quotes and so the length of the response varying slight a bit due to JSON decoding but it doesn't explain the truncation of the response. Thanks anyway :)
            – Gdcrocx
            Nov 13 at 7:46


















          up vote
          2
          down vote













          Looks like you're on Android trying to print a long string. To quote from the documentation about debugging:




          The Dart print() function outputs to the system console, which you can
          view using flutter logs (which is basically a wrapper around adb
          logcat).



          If you output too much at once, then Android sometimes discards some
          log lines. To avoid this, you can use debugPrint(), from Flutter’s
          foundation library. This is a wrapper around print which throttles the
          output to a level that avoids being dropped by Android’s kernel.




          So you could try using debugPrint instead.



          Import Flutter Package to use debugPrint - import 'package:flutter/foundation.dart';






          share|improve this answer























          • Thanks @ringil, I learnt something on debugPrint and general debugging in Flutter from the documentation but the truncation is invariably existent when I print using debugPrint and debugPrintSynchronously methods but thanks! :)
            – Gdcrocx
            Nov 13 at 7:54












          • Note that if the jsonDecode succeeds it is very unlikely to be truncated before that point or you'd end up with a decode error. The truncation is still likely happening somewhere in the printing.
            – Nate Bosch
            Nov 13 at 19:25











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53267877%2fdart-http-client-returns-truncated-response-truncation-varies-slightly-when-i-p%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote













          That's just the console truncating after so many characters.



          Notice that you are printing two different things:



          getMyPostsApiResponse.body is the json received from the server.



          json.decode(getMyPostsApiResponse.body).toString() is the decoded List's toString (which excludes the quote marks, which is why the lengths of the strings are different)






          share|improve this answer





















          • You have a point on the missing quotes and so the length of the response varying slight a bit due to JSON decoding but it doesn't explain the truncation of the response. Thanks anyway :)
            – Gdcrocx
            Nov 13 at 7:46















          up vote
          2
          down vote













          That's just the console truncating after so many characters.



          Notice that you are printing two different things:



          getMyPostsApiResponse.body is the json received from the server.



          json.decode(getMyPostsApiResponse.body).toString() is the decoded List's toString (which excludes the quote marks, which is why the lengths of the strings are different)






          share|improve this answer





















          • You have a point on the missing quotes and so the length of the response varying slight a bit due to JSON decoding but it doesn't explain the truncation of the response. Thanks anyway :)
            – Gdcrocx
            Nov 13 at 7:46













          up vote
          2
          down vote










          up vote
          2
          down vote









          That's just the console truncating after so many characters.



          Notice that you are printing two different things:



          getMyPostsApiResponse.body is the json received from the server.



          json.decode(getMyPostsApiResponse.body).toString() is the decoded List's toString (which excludes the quote marks, which is why the lengths of the strings are different)






          share|improve this answer












          That's just the console truncating after so many characters.



          Notice that you are printing two different things:



          getMyPostsApiResponse.body is the json received from the server.



          json.decode(getMyPostsApiResponse.body).toString() is the decoded List's toString (which excludes the quote marks, which is why the lengths of the strings are different)







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 at 18:56









          Richard Heap

          5,0092313




          5,0092313












          • You have a point on the missing quotes and so the length of the response varying slight a bit due to JSON decoding but it doesn't explain the truncation of the response. Thanks anyway :)
            – Gdcrocx
            Nov 13 at 7:46


















          • You have a point on the missing quotes and so the length of the response varying slight a bit due to JSON decoding but it doesn't explain the truncation of the response. Thanks anyway :)
            – Gdcrocx
            Nov 13 at 7:46
















          You have a point on the missing quotes and so the length of the response varying slight a bit due to JSON decoding but it doesn't explain the truncation of the response. Thanks anyway :)
          – Gdcrocx
          Nov 13 at 7:46




          You have a point on the missing quotes and so the length of the response varying slight a bit due to JSON decoding but it doesn't explain the truncation of the response. Thanks anyway :)
          – Gdcrocx
          Nov 13 at 7:46












          up vote
          2
          down vote













          Looks like you're on Android trying to print a long string. To quote from the documentation about debugging:




          The Dart print() function outputs to the system console, which you can
          view using flutter logs (which is basically a wrapper around adb
          logcat).



          If you output too much at once, then Android sometimes discards some
          log lines. To avoid this, you can use debugPrint(), from Flutter’s
          foundation library. This is a wrapper around print which throttles the
          output to a level that avoids being dropped by Android’s kernel.




          So you could try using debugPrint instead.



          Import Flutter Package to use debugPrint - import 'package:flutter/foundation.dart';






          share|improve this answer























          • Thanks @ringil, I learnt something on debugPrint and general debugging in Flutter from the documentation but the truncation is invariably existent when I print using debugPrint and debugPrintSynchronously methods but thanks! :)
            – Gdcrocx
            Nov 13 at 7:54












          • Note that if the jsonDecode succeeds it is very unlikely to be truncated before that point or you'd end up with a decode error. The truncation is still likely happening somewhere in the printing.
            – Nate Bosch
            Nov 13 at 19:25















          up vote
          2
          down vote













          Looks like you're on Android trying to print a long string. To quote from the documentation about debugging:




          The Dart print() function outputs to the system console, which you can
          view using flutter logs (which is basically a wrapper around adb
          logcat).



          If you output too much at once, then Android sometimes discards some
          log lines. To avoid this, you can use debugPrint(), from Flutter’s
          foundation library. This is a wrapper around print which throttles the
          output to a level that avoids being dropped by Android’s kernel.




          So you could try using debugPrint instead.



          Import Flutter Package to use debugPrint - import 'package:flutter/foundation.dart';






          share|improve this answer























          • Thanks @ringil, I learnt something on debugPrint and general debugging in Flutter from the documentation but the truncation is invariably existent when I print using debugPrint and debugPrintSynchronously methods but thanks! :)
            – Gdcrocx
            Nov 13 at 7:54












          • Note that if the jsonDecode succeeds it is very unlikely to be truncated before that point or you'd end up with a decode error. The truncation is still likely happening somewhere in the printing.
            – Nate Bosch
            Nov 13 at 19:25













          up vote
          2
          down vote










          up vote
          2
          down vote









          Looks like you're on Android trying to print a long string. To quote from the documentation about debugging:




          The Dart print() function outputs to the system console, which you can
          view using flutter logs (which is basically a wrapper around adb
          logcat).



          If you output too much at once, then Android sometimes discards some
          log lines. To avoid this, you can use debugPrint(), from Flutter’s
          foundation library. This is a wrapper around print which throttles the
          output to a level that avoids being dropped by Android’s kernel.




          So you could try using debugPrint instead.



          Import Flutter Package to use debugPrint - import 'package:flutter/foundation.dart';






          share|improve this answer














          Looks like you're on Android trying to print a long string. To quote from the documentation about debugging:




          The Dart print() function outputs to the system console, which you can
          view using flutter logs (which is basically a wrapper around adb
          logcat).



          If you output too much at once, then Android sometimes discards some
          log lines. To avoid this, you can use debugPrint(), from Flutter’s
          foundation library. This is a wrapper around print which throttles the
          output to a level that avoids being dropped by Android’s kernel.




          So you could try using debugPrint instead.



          Import Flutter Package to use debugPrint - import 'package:flutter/foundation.dart';







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 13 at 12:56









          Gdcrocx

          1217




          1217










          answered Nov 12 at 19:01









          Ringil

          3,44021025




          3,44021025












          • Thanks @ringil, I learnt something on debugPrint and general debugging in Flutter from the documentation but the truncation is invariably existent when I print using debugPrint and debugPrintSynchronously methods but thanks! :)
            – Gdcrocx
            Nov 13 at 7:54












          • Note that if the jsonDecode succeeds it is very unlikely to be truncated before that point or you'd end up with a decode error. The truncation is still likely happening somewhere in the printing.
            – Nate Bosch
            Nov 13 at 19:25


















          • Thanks @ringil, I learnt something on debugPrint and general debugging in Flutter from the documentation but the truncation is invariably existent when I print using debugPrint and debugPrintSynchronously methods but thanks! :)
            – Gdcrocx
            Nov 13 at 7:54












          • Note that if the jsonDecode succeeds it is very unlikely to be truncated before that point or you'd end up with a decode error. The truncation is still likely happening somewhere in the printing.
            – Nate Bosch
            Nov 13 at 19:25
















          Thanks @ringil, I learnt something on debugPrint and general debugging in Flutter from the documentation but the truncation is invariably existent when I print using debugPrint and debugPrintSynchronously methods but thanks! :)
          – Gdcrocx
          Nov 13 at 7:54






          Thanks @ringil, I learnt something on debugPrint and general debugging in Flutter from the documentation but the truncation is invariably existent when I print using debugPrint and debugPrintSynchronously methods but thanks! :)
          – Gdcrocx
          Nov 13 at 7:54














          Note that if the jsonDecode succeeds it is very unlikely to be truncated before that point or you'd end up with a decode error. The truncation is still likely happening somewhere in the printing.
          – Nate Bosch
          Nov 13 at 19:25




          Note that if the jsonDecode succeeds it is very unlikely to be truncated before that point or you'd end up with a decode error. The truncation is still likely happening somewhere in the printing.
          – Nate Bosch
          Nov 13 at 19:25


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53267877%2fdart-http-client-returns-truncated-response-truncation-varies-slightly-when-i-p%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Guess what letter conforming each word

          Port of Spain

          Run scheduled task as local user group (not BUILTIN)