Currently, I have the following JSON:
var user = {
"id": Provider.of<UserProvider>(context, listen: false).id,
"name": Provider.of<UserProvider>(context, listen: false).name,
"desc": Provider.of<UserProvider>(context, listen: false).desc,
"title": Provider.of<UserProvider>(context, listen: false).title
};
var finalJson = json.encode(user);
Now I want to exclude desc key and value if Provider.of(context, listen: false).desc == null.
I do not want to include key and value if anyone the value is null.
How can I achieve that?