Here is my code below :-
var typeId = message!=null?message.data["payload"]:payload;
if(typeId["type"]=="XYZ"){
//Navigate to a screen
}else{}
this is not working and throwing exception.
Your exception is because of you've not decoded your message.data["payload"]
.
Because Data payload contains custom key-value pairs not a JSON format. you have to decode it.
here is your solution:
var typeId = message!=null ? json.decode(message.data["payload"]) : payload;
if(typeId["type"]=="XYZ"){
//Navigate to a screen
}
else{
}
happy coding...