'How to get data that have a string we specify

I wanted to get only the data that have a date i want in it .

Here's the data i get

 "Schedule": {
    "data": [
        {
            "Day": "Monday",
            "Date": "2022-4-2"
        },
        {
            "Day": "Tuesday",
            "Date": "2022-4-3"
        },
        {
            "Day": "Wednesday",
            "Date": "2022-4-4"
        },
    ]
}}

I only wanted to show 1 data each screen Using the date.

enter image description here

the result i want is everytime the date was inputted inside a textfield, the data shown is the data that have the same date.

Text Input : 2022-4-2
Data Output : Monday

or

Text Input : 2022-4-4
Data Output : Wednesday

without changing the database



Solution 1:[1]

You need a class that represents the data item. So we create Data class with 2 fields like this.

class Data {
  String Day;
  String Date;
  Data(this.Day, this.Date);
  factory Data .fromJson(dynamic json) {
    return Data (json['Day'] as String, json['Date'] as String);
  }
  @override
  String toString() {
    return '{ ${this.Day}, ${this.Date} }';
  }
}

After you can use a Data model

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Paresh Mangukiya