0

I developed an application with native android and native iOS, but now I want to recreate it using flutter.

some of the requests that I done successfully in native android and iOS are returning 302 status code in flutter.

the problem is that I can't get 302 response on postman so I may understand what is the problem, it keep happening only on flutter.

  Map<String, String> headers = {'Content-Type': 'application/json', "Authorization": "Bearer ${App.token}"};

  Response response = await post(URL, body: jsonEncode({"FullName": name}), headers: headers);
  if (checkIfSuccessful(response)) {
    return true;
  } else {
    return false;
  }
SinaMN75
  • 6,742
  • 5
  • 28
  • 56

1 Answers1

0

You can use flutter DevTools to inspect the network; get it in the android studio by pressing this icon

enter network tab and begin recording, you should be able to analyze network traffic and understand the problem

in your code you can check for response status code like

Response response = await post(URL, body: jsonEncode({"FullName": name}), headers: headers);
switch (response.statusCode){
  case (200){
    print('Ok');
    break;
  }
  case (302){
    print('Handling redirect');
    break;
  }
}
Loki
  • 659
  • 1
  • 8
  • 18