1
votes

I am working with http request. suddenly on my request, i was getting response status code as "200" so that my api is working.. but, upon my response body that return is incomplete. by the way, this is my resources used.

  String APILink = "http://10.12.50.46:9191";
  String compressedString2;

 Future<SuccessData> getSession() async {
        http.Response response2=await http.post(
          Uri.encodeFull(APILink+"/Mobile/StartSession"),
          headers:{
            "Auth-Key":"InSys-dev-key-001 ",
          },body:compressedString2,
        );
        print("Compressed JSON:"+compressedString2);
        print(response2.statusCode);
      var dataGather2 = json.decode(response2.body);
      print(response2.body);
    }

this is my actual responseupon using insomnia (Rest API)

enter image description here

and here is my print data upon my logcat:

enter image description here

if you notice, my return data upon "ResultSet" is not complete.. also the other data do be fetch like status, errormsg,and tag is not viewed.

1

1 Answers

4
votes

Print function will not print everything
You can see print() statements in Flutter are truncated in flutter run output https://github.com/flutter/flutter/issues/22665

Solution 1:
From https://github.com/flutter/flutter/issues/22665#issuecomment-580613192
You can use the following two code snippet

void logLongString(String s) {
    if (s == null || s.length <= 0) return;
    const int n = 1000;
    int startIndex = 0;
    int endIndex = n;
    while (startIndex < s.length) {
      if (endIndex > s.length) endIndex = s.length;
      print(s.substring(startIndex, endIndex));
      startIndex += n;
      endIndex = startIndex + n;
    }
} 

https://github.com/flutter/flutter/issues/22665#issuecomment-513476234

void printWrapped(String text) {
  final pattern = new RegExp('.{1,800}'); // 800 is the size of each chunk
  pattern.allMatches(text).forEach((match) => print(match.group(0)));
}

Solution 2: In Android Studio Debug mode, set break point and copy variable content in Variables window
enter image description here