Reputation: 7945
How can I ignore a key when using json.encode
?
Something like this:
final map = json.decode(json.encode(routine), reviver: (key, value) {
if (key == "id") {
return null;
}
return value;
});
But this way my map has a key id
with value null
. I want my map to not have the id key.
Any Idea?
Upvotes: 2
Views: 1278
Reputation: 3156
You can remove the key.
routine.remove("id");
final map = json.decode(json.encode(routine));
Upvotes: 1