I'm new in Flutter , got the following error type 'String' is not a subtype of type 'int' of 'index' , any help, please?
''' if(response.statusCode ==200)
String jSonData = response.body;
var decodeData = jsonDecode(jSonData) ;
return decodeData;
'''
CodePudding user response:
The problem is String jSonData
The response that you are getting is not a String.
try changing your code to
if(response.statusCode ==200) {
final decodeData = jsonDecode(response.body) as Map<String, dynamic>;
return decodeData;
}
this should solve your problem
CodePudding user response:
the status code 200 is coming on int data type and you are trying to parse to to the string check the data type agin and please add your full code still having doubt let me know