final Map<String, dynamic> interactiveData = {
"title": "Survey",
"formFields": [
{
"elementType": "textInput" ,
"elementId": "name",
"optional": false,
"label": "Name",
"placeholder": {
"text": "Enter text here"
}
},
{
"elementType": "textInput",
"elementId": "age",
"optional": true,
"label": "Age",
"maxLines": 1,
"placeholder": {
"text": "Enter text here"
}
},
{
"elementType": "Select",
"elementId": "checkBox1",
"optional": true,
"label": "Check box element",
"defaultValue":["chk_option_2"],
"options" : [
{
"label": "Option 1",
"value": "chk_option_1",
},
{
"label": "Option 2",
"value": "chk_option_2",
}
]
},
{
"elementType": "dropdown",
"elementId": "gender",
"optional": false,
"label": "Gender",
"defaultValue":"male",
"options" : [
{
"label": "Male",
"value": "male",
},
{
"label": "Female",
"value": "female",
}
]
},
],
"submitElement": {
"elementType": "button",
"elementId": "submitButton",
"buttonText": "Submit",
"disableAfterInteracted": false,
"action": {
"actionType": "urlNavigation",
"url": "https://www.cometchat.com/",
}
},
};
InteractiveMessage interactiveMessage =
InteractiveMessage(interactiveData: interactiveData,
receiverUid: "cometchat-uid-3", //Replace this with receiver id
type: "form",
receiverType: "user",//replace this with receiver type
allowSenderInteraction: true,
muid: DateTime.now().millisecondsSinceEpoch.toString(),
interactionGoal: InteractionGoal(
type: InteractionGoalType.none
)
);
CometChat.sendInteractiveMessage(interactiveMessage, onSuccess: (InteractiveMessage message){
print(interactiveMessage);
}, onError: (CometChatException excep){
print(excep);
});