In here i want to make a condition if the dropdown box select the last option it will show new box but i don't know how to make that condition. What i use now is the condition where the option is "Other Impression" selected but the api has 2 language so i cannot hard code the condition. Maybe i think it's like dropdownOption.lastIndexOf
.... i don't know
This is the Json
List dummyDropdownOption = [
{
"value": 1,
"label": "Sistem Kemudi otomatis dapat diandalkan",
},
{
"value": 2,
"label": "Mobilitas tanpa awak mematuhi rambu dan aturan lalu lintas",
},
{
"value": 3,
"label": "Mobilitas tanpa awak memiliki kondisi kebersihan yang baik.",
},
{
"value": 4,
"label": "Other impressions",
},
];
The condition i use for now
(dropdownValue1 == 'Other impressions')
?
CodePudding user response:
In Dart, you also have a last
property on the List
. Doc
void main() {
print(dummyDropdownOption.last);
}
Console log
{value: 4, label: Other impressions}
CodePudding user response:
You can get last index item like below.
dummyDropdownOption[dummyDropdownOption.length - 1]