json.decode() Unexpected end of input (at character 1)

后端 未结 3 1257
面向向阳花
面向向阳花 2021-02-19 07:33

I am facing a anonymus closure error in flutter while signing in a user. It worked a few days before but now its not working, I dont no why. So please help and thanks in advance

相关标签:
3条回答
  • 2021-02-19 08:04

    I also have similar type of error, Be make sure that the argument of .decode method shouldn't be empty object. Instead of using this line:

    var body = json.decode(response.body);
    

    Try

    if(response.body.isNotEmpty) {
        json.decode(response.body);
    }
    

    Do try this, hope it will work for you.

    0 讨论(0)
  • 2021-02-19 08:07

    I had similar type of problem, i tried everything but eventually the problem was that I was using http intead of using https even though the apis was in https, i forgot to add s at in http. After changing to https from http the error was gone.

    0 讨论(0)
  • 2021-02-19 08:24

    Print your body and double check you aren't trying to decode an array rather than on object.

    0 讨论(0)
提交回复
热议问题