0

I am sending request on Flutter Web Debug mode to a local back-end server using this code:

final response = await http.post(
          Uri.parse('http://localhost/api/user/login'),
          body: convert.jsonEncode(loginRequestBody),
          headers: {'content-type': 'application/json'});

it works fine on mobile but in Web it shows this error

XMLHttpRequest error.
Error: Failed assertion: boolean expression must not be null
    at Object.throw_ [as throw] (http://localhost:58442/dart_sdk.js:5374:11)
    at Object.test (http://localhost:58442/dart_sdk.js:5666:32)
    at login_user_data.LogInUserData.new.<anonymous> (http://localhost:58442/packages/tumblrx/screens/login_user_data.dart.lib.js:241:93)
    at Generator.next (<anonymous>)
    at http://localhost:58442/dart_sdk.js:40646:33
    at _RootZone.runUnary (http://localhost:58442/dart_sdk.js:40503:58)
    at _FutureListener.thenAwait.handleValue (http://localhost:58442/dart_sdk.js:35432:29)
    at handleValueCallback (http://localhost:58442/dart_sdk.js:36017:49)
    at Function._propagateToListeners (http://localhost:58442/dart_sdk.js:36055:17)
    at _Future.new.[_completeError] (http://localhost:58442/dart_sdk.js:35905:23)
    at async._AsyncCallbackEntry.new.callback (http://localhost:58442/dart_sdk.js:35944:31)
    at Object._microtaskLoop (http://localhost:58442/dart_sdk.js:40808:13)
    at _startMicrotaskLoop (http://localhost:58442/dart_sdk.js:40814:13)
    at http://localhost:58442/dart_sdk.js:36279:9

how can I solve that?

Ammar Mohamed
  • 513
  • 1
  • 6
  • 16

1 Answers1

0

Do you use any models to parse the response? The most likely you're awaiting for the boolean field that isn't being stored inside the backend response. But I'm not sure I know the reason why it's working on mobile

Alex Verbitski
  • 499
  • 3
  • 12