-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssignment_5.dart
66 lines (60 loc) · 1.92 KB
/
Assignment_5.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
void main() {
//Assignment 5 In Dart
List<Map<String, dynamic>> Tasks = [
{
"taskName": "Do Assignment 5",
"isCompleted": false,
"submissionDate": 29,
},
{
"taskName": "Do Assignment 4",
"isCompleted": true,
"submissionDate": 26,
},
{
"taskName": "Do Assignment 3",
"isCompleted": true,
"submissionDate": 19,
},
{
"taskName": "Do Assignment 2",
"isCompleted": false,
"submissionDate": 12,
},
{"taskName": "Do Assignment 1", "isCompleted": true, "submissionDate": 5}
];
List<Map<String, dynamic>> CompletedTask = [];
List<Map<String, dynamic>> TaskWithsubmission_dates_between_10_20 = [];
var isCompleted = Tasks.where((element) => element["isCompleted"] == true);
CompletedTask.addAll(isCompleted);
CompletedTask.forEach((element) {
element.update("taskName", (value) => value + " Completed");
});
var TaskWithsubmission = Tasks.where((element) =>
element["submissionDate"] >= 10 && element["submissionDate"] <= 20);
TaskWithsubmission_dates_between_10_20.addAll(TaskWithsubmission);
print("===== List OF UnFiltered Tasks =====\n");
print(Tasks);
print("\n===== List OF Only Completed Tasks =====\n");
print(CompletedTask);
print("\n===== List OF Tasks With Submission Dates Between 10 To 20 =====\n");
print(TaskWithsubmission_dates_between_10_20);
// Tasks.forEach((element) {
// element.forEach((key, value) {
// if (key == "isCompleted" && value == true) {
// CompletedTask.add(element));
// }
// if (key == "submissionDate" && value >= 10 && value <= 20) {
// TaskWithsubmission_dates_between_10_20.add(element);
// }
// });
// //print(element);
// });
// CompletedTask.forEach((element) {
// print(element);
// });
// print("========");
// TaskWithsubmission_dates_between_10_20.forEach((element) {
// print(element);
// });
}