Adding the possibility to specify a default entry mode for the material calendar - v2.0.1

This commit is contained in:
Gaspard Merten 2021-04-03 21:29:40 +02:00
parent fa2bdd1d4e
commit ddcb665d2f
4 changed files with 79 additions and 64 deletions

View file

@ -1,59 +1,38 @@
## 0.0.1
##2.0.1
* Initial version
* Adding the ability to specify the entry mode for the material date picker.
## 0.0.2
##2.0.0
* Fixing README.md
* Updating package description
* Formatting with DartFM
* Migrating to null-safety
## 0.1.0
* Updating documentation!
##1.0.5
## 0.1.1
* Removing unused variables
* Improving description
* Formatting with DartFM!
## 0.1.2
##1.0.4
* Fixing an incorrect boolean (iOS picker was inverted with the Android one)
* Fixing critical issue
## 0.2.0
##1.0.3
* DateFormField now extends FormField. All issues related to this are now fiex
* The style of the DateField (and by extension the one of DateFormField) is now rigorously applying the theme or any customization.
* Improving package description
## 0.2.1
##1.0.2
* Adding support for Flutter web
* Improving package description
## 0.2.2
##1.0.1
* Auto-formatting with dart-fm to meet pub.dev requirements
* Removing the ripple effect
## 0.3.0
##1.0.0
Breaking changes:
* No more const constructor.
Deprecated:
* DateField and DateFormField are now deprecated and will be removed in the next version, please consider switching to
DateTimeField and DateTimeFormField.
Improvements:
* Adding support for time. Now you can ask the user for a time, a date or both.
* Improving performances by setting default value in the constructor.
* Adding .time constructor for the DateField widget only.
##0.3.1
* Adding the possibility to style the text with TextStyle
##0.3.2
* Formating with dartfm
* Full support for input decoration
* New standardized usage, many deprecations
##0.3.3
@ -62,32 +41,59 @@ Improvements:
Breaking change:
* Removing the label property, please consider using the InputDecoration to customize the label.
##1.0.0
##0.3.2
* Full support for input decoration
* New standardized usage, many deprecations
* Formating with dartfm
##1.0.1
##0.3.1
* Removing the ripple effect
* Adding the possibility to style the text with TextStyle
##1.0.2
## 0.3.0
* Improving package description
Breaking changes:
* No more const constructor.
##1.0.3
Deprecated:
* DateField and DateFormField are now deprecated and will be removed in the next version, please consider switching to
DateTimeField and DateTimeFormField.
* Improving package description
Improvements:
* Adding support for time. Now you can ask the user for a time, a date or both.
* Improving performances by setting default value in the constructor.
* Adding .time constructor for the DateField widget only.
##1.0.4
## 0.2.2
* Fixing critical issue
* Auto-formatting with dart-fm to meet pub.dev requirements
##1.0.5
## 0.2.1
* Removing unused variables
* Improving description
* Adding support for Flutter web
##2.0.0
## 0.2.0
* Migrating to null-safety
* DateFormField now extends FormField. All issues related to this are now fiex
* The style of the DateField (and by extension the one of DateFormField) is now rigorously applying the theme or any customization.
## 0.1.2
* Fixing an incorrect boolean (iOS picker was inverted with the Android one)
## 0.1.1
* Formatting with DartFM!
## 0.1.0
* Updating documentation!
## 0.0.2
* Fixing README.md
* Updating package description
* Formatting with DartFM
## 0.0.1
* Initial version

View file

@ -6,7 +6,7 @@
Contains DateTimeField and DateTimeFormField which allows the user to pick a DateTime from an input field! Depending on
the mode, it can ask the user the time, the date or both at the same time ;) !
<img src='https://raw.githubusercontent.com/GaspardMerten/date_field/master/example/example.PNG' height='250px'></img>
<img src='https://raw.githubusercontent.com/GaspardMerten/date_field/master/example/demo.gif' height='250px'></img>
## Usage
@ -15,7 +15,7 @@ In the `pubspec.yaml` of your flutter project, add the following dependency:
```yaml
dependencies:
...
date_field: ^1.0.4
date_field: ^2.0.1
```
In your library add the following import:
@ -40,7 +40,7 @@ You can also specify whether you would like to ask the user for a date, a time o
## Example
The following picture illustrates some of the things you can do with this package.
The following picture illustrates some things you can do with this package.
<img src='https://raw.githubusercontent.com/GaspardMerten/date_field/master/example/demo.gif' height='250px'></img>

View file

@ -30,6 +30,7 @@ class DateTimeFormField extends FormField<DateTime> {
DateTime? lastDate,
ValueChanged<DateTime>? onDateSelected,
InputDecoration? decoration,
DatePickerEntryMode initialEntryMode = DatePickerEntryMode.calendar,
DatePickerMode initialDatePickerMode = DatePickerMode.day,
DateTimeFieldPickerMode mode = DateTimeFieldPickerMode.dateAndTime,
}) : super(
@ -65,6 +66,7 @@ class DateTimeFormField extends FormField<DateTime> {
selectedDate: field.value,
enabled: enabled,
mode: mode,
initialEntryMode: initialEntryMode,
dateTextStyle: dateTextStyle,
);
},
@ -89,6 +91,7 @@ class DateTimeField extends StatelessWidget {
this.decoration,
this.enabled = true,
this.mode = DateTimeFieldPickerMode.dateAndTime,
this.initialEntryMode = DatePickerEntryMode.calendar,
this.dateTextStyle,
DateTime? firstDate,
DateTime? lastDate,
@ -105,6 +108,7 @@ class DateTimeField extends StatelessWidget {
this.decoration,
this.enabled,
this.dateTextStyle,
this.initialEntryMode = DatePickerEntryMode.calendar,
DateTime? firstDate,
DateTime? lastDate,
}) : initialDatePickerMode = null,
@ -144,6 +148,9 @@ class DateTimeField extends StatelessWidget {
/// [TextStyle] of the selected date inside the field.
final TextStyle? dateTextStyle;
/// The initial entry mode for the material date picker dialog
final DatePickerEntryMode initialEntryMode;
/// Shows a dialog asking the user to pick a date !
Future<void> _selectDate(BuildContext context) async {
final DateTime initialDateTime = selectedDate ?? DateTime.now();
@ -173,6 +180,7 @@ class DateTimeField extends StatelessWidget {
context: context,
initialDatePickerMode: initialDatePickerMode!,
initialDate: initialDateTime,
initialEntryMode: initialEntryMode,
firstDate: firstDate,
lastDate: lastDate,
);
@ -193,11 +201,12 @@ class DateTimeField extends StatelessWidget {
if (_selectedTime != null) {
_selectedDateTime = DateTime(
_selectedDateTime.year,
_selectedDateTime.month,
_selectedDateTime.day,
_selectedTime.hour,
_selectedTime.minute);
_selectedDateTime.year,
_selectedDateTime.month,
_selectedDateTime.day,
_selectedTime.hour,
_selectedTime.minute,
);
}
}

View file

@ -1,6 +1,6 @@
name: date_field
description: A widget in the form of a field that lets people choose a date, a time or both.
version: 2.0.0
version: 2.0.1
homepage: 'https://github.com/GaspardMerten/date_field'
environment: