1

I have built one asp.net web api for my angular application which is working fine. I'm going to use same api in Flutter but surprisingly I'm not getting full object in response.body. I observed that, response.body is containing only 1023 chars.

final response = await http.post(
        apiUrl,
        body: body,
        headers: {
          'Content-Type': 'application/json;',
          'Accept': 'application/json ',
          'Authorization': 'Bearer $_token',
        });
print(response.body) // response.body string length is 1023.

Thank in advance looking at my issue.

3
  • 1
    Did you count the string printed or did you print the string length. FYI print method has a length limit. If you have long text, you should use debugPrint. Also, there might be a response error in the body Commented Jan 14, 2020 at 11:24
  • Check this out stackoverflow.com/questions/55361422/… Commented Jan 14, 2020 at 12:10
  • print(response.body.length.toString()) gives me 6375 . It seems like data is there but print has some limitation. @danypata, I tried with debugPrint, but response.body is still limited to 1023 chars. Commented Jan 14, 2020 at 12:49

1 Answer 1

2

i had a similar issue it seems that print has a char limit to unlock use this change number to match ur response chars or just set a higher number and use printWrapped (response.body); instead

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)));
   }
Sign up to request clarification or add additional context in comments.

1 Comment

Worked for me. (only thing that before every bit of content, I/flutter (17388): is printed.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.