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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
import 'marked_date.dart';
import 'package:flutter/material.dart';
class MultipleMarkedDates {
List<MarkedDate> markedDates;
MultipleMarkedDates({required this.markedDates});
void add(MarkedDate markedDate) {
markedDates.add(markedDate);
}
void addRange(MarkedDate markedDate, {int plus = 0, int minus = 0}) {
this.add(markedDate);
if (plus > 0) {
int start = 1;
MarkedDate newAddMarkedDate;
while (start <= plus) {
newAddMarkedDate = new MarkedDate(
color: markedDate.color,
date: markedDate.date.add(Duration(days: start)),
textStyle: markedDate.textStyle,
);
this.add(newAddMarkedDate);
start += 1;
}
}
if (minus > 0) {
int start = 1;
MarkedDate newSubMarkedDate;
while (start <= minus) {
newSubMarkedDate = new MarkedDate(
color: markedDate.color,
date: markedDate.date.subtract(Duration(days: start)),
textStyle: markedDate.textStyle,
);
this.add(newSubMarkedDate);
start += 1;
}
}
}
void addAll(List<MarkedDate> markedDates) {
this.markedDates.addAll(markedDates);
}
bool remove(MarkedDate markedDate) {
return markedDates.remove(markedDate);
}
void clear() {
markedDates.clear();
}
bool isMarked(DateTime date) {
final results = markedDates.firstWhere((element) => element.date == date,
orElse: () => MarkedDate(color: Colors.black, date: DateTime(0)));
return results.date.year == date.year;
}
Color getColor(DateTime date) {
final results = markedDates.firstWhere((element) => element.date == date,
orElse: () => MarkedDate(color: Colors.black, date: DateTime(0)));
return results.color;
}
DateTime getDate(DateTime date) {
final results = markedDates.firstWhere((element) => element.date == date,
orElse: () => MarkedDate(color: Colors.black, date: DateTime(0)));
return results.date;
}
TextStyle? getTextStyle(DateTime date) {
final results = markedDates.firstWhere((element) => element.date == date,
orElse: () => MarkedDate(color: Colors.black, date: DateTime(0)));
return results.textStyle;
}
}
|