[SOLVED] Flutter : Unhandled Exception: type ‘int’ is not a subtype of type ‘String’ in type cast

Problem

I’m Calling An API to update my data and I got this error, the Error Says,

E/flutter (32582): type 'int' is not a subtype of type 'String' in type cast

Solution

Step 1: use "content-type": "application/json" in header

Step 2: encode your body like jsonEncode( {"param1": 10, "param2":20,"param3": "abc","param4": true})

Example Code Like

headers: {
      "content-type": "application/json",
    },
    body:jsonEncode( {
      "qualificationId": 10,
      "year":2001,
      "instituteName": "example",
      "isActive": true
    })

That’s it.

Thanks for Reading.

Keep Coding.

4 1 vote
Article Rating
Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
sourav
sourav
8 months ago
  1. _CastError (type ‘List<String>’ is not a subtype of type ‘String’ in type cast)
1
0
Would love your thoughts, please comment.x
()
x