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

后端 未结 3 1232
面向向阳花
面向向阳花 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.

提交回复
热议问题