title: Unhandled Exception: type 'String' is not a subtype of type 'bool'
body: <p>Hi I have an issue with Flutter.
  I get this Exception:</p>
  
  <p>Unhandled Exception: type 'String' is not a subtype of type 'bool'</p>
  
  <p>I try to check if token exists from a response.</p>
  
  <pre><code>    var res = await ApiService().postData(loginData, 'login');
  var body = json.decode(res.body);
  if (json.decode(res.body)['token']) {
    SharedPreferences localStorage = await SharedPreferences.getInstance();
    localStorage.setString('token', body['token']);
    localStorage.setString('user', json.encode(body['user']));
    Navigator.push(
        context, new MaterialPageRoute(builder: (context) =&gt; UserHome()));
  } else {
    print(body['message']);
  }
  </code></pre>