Home > Software design >  remove specific item range from list
remove specific item range from list

Time:12-02

i have 2 dropdowns 1st is toDate and 2nd is fromDate with 1 list of months to be displayed.

List<String> month = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
];

in the first dropdown, all the list is shown to select but in the 2nd dropdown, I want to show all values coming after the selected 1st dropdown value.

for example - : in the first dropdown, I selected 'March' the 2nd dropdown the list displayed should be after 'March'.

How do I do it? please help.

CodePudding user response:

void main() {
  List<String> month = [
    'January',
    'February',
    'March',
    'April',
    'May',
    'June',
    'July',
    'August',
    'September',
    'October',
    'November',
    'December',
  ];
  var choice = 'March';
  var ind = month.indexOf(choice);
  if (ind > 0) {
    print(month.skip(ind   1));
  }
}
  • Related