Tanveer
Tanveer

Reputation: 33

API call in Flutter (dart)

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.

Upvotes: 1

Views: 564

Answers (1)

Rowid Al-deeb
Rowid Al-deeb

Reputation: 23

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)));
   }

Upvotes: 2

Related Questions