Reputation: 446
I have a dynamic UI which maybe dropdown or textField!
I need to prepare map to send to backend. Below is map format that i need to prepare from the dynamic UI,
Map temp;
temp = {
"receiver": {
"Bank": {"accounnt": '123'},
}
};
if(temp['receiver']['school'] == null){
temp['receiver']['school'] = '12';
}
But where I am getting error when I am trying to add temp['receiver']['school'] = '12';
. The error states that, type 'String' is not a subtype of type 'Map<String, String>' of 'value.'
I want to create a map in below format,
"receiver": {
"bank_account": {
"swift_bic": "XXX",
"account_number": "225225"
},
"reason_for_sending": "Family"
}
Error image: https://i.sstatic.net/5yg2t.png
Upvotes: 1
Views: 629
Reputation: 1294
Try This:
void main() {
Map<String,Map<String,dynamic>> temp;
temp = {
"receiver": {
"Bank": {"accounnt": '123'}
}
};
if(temp['receiver']!['school'] == null){
temp['receiver']!['school'] = '12';
}
print(temp);
}
Upvotes: 1