I hope you can help me, I have this json to send in a request
{
"taxpayer": _person,
"customerType": _dropdownTypeClient,
"rfc": _rfc.text,
"name": _name.text,
"fatherSurname": _firstName.text,
"motherSurname": _lastName.text,
"businessName": _razonSocial.text,
"contact": _contact.text,
"phone": _phone.text,
"cell": _cellphone.text,
"taxRegime": _dropdownTax,
"mailList": [
{"mail": _email.text},
{"mail": _emailTwo.text}
],
"workType": _dropdownWorkType,
"howToContact": _dropdownHowToContact
}
but i want to send the mailList as a real List, because th emailTwo is optional and when I send the information the DB counts the empty value. How i do the converse ? I tried this for simplicity but it didnt work.
//List mails = [];
//mails.add(_email.text);
//if (_emailTwo.text.isNotEmpty) {
//mails.add(_emailTwo.text);
//}
2
Answers
You can use a simple
if
inside the map literal, like so:It is impossible to know exactly why is your attempt "not working" without you giving the error messages. But we can guess, maybe you should try this: