I am trying to create a filter where I need to filter using a range of Dates.
for eg. from 2021-05-21
to 2021-08-31
.
I got dateA
= 2021-05-21
, dateB
= 2021-08-31
.
Suppose I have a list of Dates and list of Items below respectively:
the format of Date is yyyy-mm-dd
.
datesList
=
[ "2021-05-07",
"2021-06-09", //
"2021-05-12",
"2021-08-12", //
"2021-04-15",
"2021-07-08", //
"2021-05-02",
"2021-06-31", //
"2021-08-18", //
"2021-02-09" ]
itemsList
=
[ "Apple",
"Mango", //
"Apple",
"Pineapple, //
"Cinnamon",
"Apple", //
"Mango",
"Banana", //
"Orange", //
"Orange" ]
Note: Here, for the 1st element in datesList
for eg. "2021-05-07"
, the respective item is the 1st item in itemsList
which is "Apple"
. i.e. both are having same indices, and both the lists are having same number of elements as well.
How to find only the items in a particular date range?
Let's say I need to filter from 2021-05-21
to 2021-08-31
.
Then I should get only itemList[2]
, itemList[4]
, itemList[6]
, itemList[8]
, itemList[9]
from the itemsList
as Output.
which is basically ["Mango", "Pineapple", "Apple", "Banana", "Orange"]
As only these items are present within this date range are needed to be filtered. (dateA
= 2021-05-21
, dateB
= 2021-08-31
.)
I couldn't even start as I am new in Flutter/Dart.
Kindly suggest me to proceed.