You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/date_range_form_field.dart
+107-2Lines changed: 107 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6,27 +6,126 @@ class DateRangeField extends FormField<DateTimeRange> {
6
6
DateRangeField(
7
7
{Key key,
8
8
@requiredBuildContext context,
9
+
10
+
/// This is the earliest date a user can select.
11
+
///
12
+
/// If null, this will default to DateTime.now().
9
13
DateTime firstDate,
14
+
15
+
/// This is the latest date a user can select.
16
+
///
17
+
/// If null, this will default to 5 years from now.
10
18
DateTime lastDate,
19
+
20
+
/// currentDate represents the the current day (today).
21
+
///
22
+
/// If null, this default to DateTime.now().
11
23
DateTime currentDate,
24
+
25
+
/// This argument determines which mode the showDateRangePicker will initially display in.
26
+
///
27
+
/// It defaults to a scrollable calendar month grid ([DatePickerEntryMode.calendar]).
28
+
/// It can also be set to display two text input fields ([DatePickerEntryMode.input]).
12
29
DatePickerEntryMode initialEntryMode,
30
+
31
+
/// This is the label displayed at the top of the [showDateRangePicker] dialog.
32
+
///
33
+
/// If null, this defaults to 'Select Date Range'.
13
34
String helpText,
35
+
36
+
/// This is the label on the cancel button for the text input mode.
37
+
///
38
+
/// If null, this defaults to 'CANCEL'.
14
39
String cancelText,
40
+
41
+
/// This is the label on the ok button for the text input mode.
42
+
///
43
+
/// If null, this defaults to 'OK'.
15
44
String confirmText,
45
+
46
+
/// This is the label on the save button for the calendar view.
47
+
///
48
+
/// If null, this defaults to 'SAVE'.
16
49
String saveText,
50
+
51
+
/// This is the error message displayed when the input text is not a proper date format.
52
+
///
53
+
/// For example, if the date format was 'MM-dd-yyyy', and the user enters 'Monday' this message will be displayed.
54
+
/// If null, this defaults to 'Invalid format.'.
17
55
String errorFormatText,
56
+
57
+
/// This is the error message displayed when an input is not a selectable date.
58
+
///
59
+
/// For example, if firstDate was set to 09-01-2020, and the user enters '09-01-2019' this message will be displayed.
60
+
/// If null, this defaults to 'Out of range.'.
18
61
String errorInvalidText,
62
+
63
+
/// This is the error message displayed when an input is not a valid date range.
64
+
///
65
+
/// For example, if the user selects a startDate after the endDate this message will be displayed.
66
+
/// If null, this defaults to 'Invalid range.'.
19
67
String errorInvalidRangeText,
68
+
69
+
/// This is the label for the start date input text field.
70
+
///
71
+
/// If null, this defaults to 'Start Date'.
20
72
String fieldStartLabelText,
73
+
74
+
/// This is the label for the end date input text field.
75
+
///
76
+
/// If null, this default to 'End Date'.
21
77
String fieldEndLabelText,
78
+
79
+
/// This is the width of the widget.
80
+
///
81
+
/// If null, this defaults to the width of the screen.
22
82
double width,
83
+
84
+
/// This is the margins of the widget.
85
+
///
86
+
/// If null, this defaults to EdgeInsets.all(15.0).
23
87
EdgeInsets margin,
24
-
FocusNode focusNode,
88
+
89
+
/// This is where you tell the widget what to do when the form is saved.
90
+
///
91
+
/// For example:
92
+
/// ```dart
93
+
/// onSaved: (value) {
94
+
/// setState(() {
95
+
/// myDateRange = value;
96
+
/// });
97
+
/// }
98
+
/// ```
25
99
FormFieldSetter<DateTimeRange> onSaved,
100
+
101
+
/// This is where you can validate the user input.
102
+
///
103
+
/// For example:
104
+
/// ```dart
105
+
/// validator: (value) {
106
+
/// if (value.start.isBefore(DateTime.now()) {
107
+
/// return 'Please enter a later start date.';
108
+
/// }
109
+
/// return null;
110
+
/// }
111
+
/// ```
26
112
FormFieldValidator<DateTimeRange> validator,
113
+
114
+
/// This required field is the initial DateTimeRange value of the widget.
115
+
///
116
+
/// This value will be displayed upon first opening the dialog, and if the user does not choose another value it will be saved when the onSaved method is called.
27
117
@requiredDateTimeRange initialValue,
28
118
bool autoValidate =false,
119
+
120
+
/// This is the format the widget will use for dates.
121
+
///
122
+
/// Any valid format from the intl package is usable.
123
+
/// If null, this will default to 'MM-dd-yyyy'.
29
124
DateFormat dateFormat,
125
+
126
+
/// This is how to decorate and customize the appearance of the widget.
127
+
///
128
+
/// If null, this will use the defaults from the theme.
Copy file name to clipboardExpand all lines: pubspec.yaml
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
name: date_range_form_field
2
-
description: A Flutter package to create a DateRange FormField widget. The widget enables users to enter a date range that is saved into a DateTimeRange object, and supports InputDecoration and DateFormat properties.
2
+
description: A Flutter package to create a widget which allows the user to input a DateRange into a FormField.
0 commit comments