Formatting with dart-fm
This commit is contained in:
parent
c520484ef8
commit
97da6f5955
3 changed files with 71 additions and 70 deletions
|
@ -28,3 +28,7 @@
|
|||
## 0.2.1
|
||||
|
||||
* Adding support for Flutter web
|
||||
|
||||
## 0.2.2
|
||||
|
||||
* Auto-formatting with dart-fm to meet pub.dev requirements
|
|
@ -12,9 +12,8 @@ import 'package:intl/intl.dart';
|
|||
/// pass a [GlobalKey] to the constructor and use [GlobalKey.currentState] to
|
||||
/// save or reset the form field.
|
||||
class DateFormField extends FormField<DateTime> {
|
||||
|
||||
DateFormField({
|
||||
Key key,
|
||||
DateFormField(
|
||||
{Key key,
|
||||
FormFieldSetter<DateTime> onSaved,
|
||||
FormFieldValidator<DateTime> validator,
|
||||
DateTime initialValue,
|
||||
|
@ -26,8 +25,8 @@ class DateFormField extends FormField<DateTime> {
|
|||
this.label = 'Select date',
|
||||
this.dateFormat,
|
||||
this.decoration,
|
||||
this.initialDatePickerMode = DatePickerMode.day
|
||||
}) : super(
|
||||
this.initialDatePickerMode = DatePickerMode.day})
|
||||
: super(
|
||||
key: key,
|
||||
initialValue: initialValue,
|
||||
onSaved: onSaved,
|
||||
|
@ -43,6 +42,7 @@ class DateFormField extends FormField<DateTime> {
|
|||
}
|
||||
field.didChange(value);
|
||||
}
|
||||
|
||||
return DateField(
|
||||
label: label,
|
||||
firstDate: firstDate,
|
||||
|
@ -80,7 +80,6 @@ class DateFormField extends FormField<DateTime> {
|
|||
/// (optional) Let you choose the [DatePickerMode] for the date picker! (default is [DatePickerMode.day]
|
||||
final DatePickerMode initialDatePickerMode;
|
||||
|
||||
|
||||
@override
|
||||
_DateFormFieldState createState() => _DateFormFieldState();
|
||||
}
|
||||
|
@ -92,7 +91,6 @@ class _DateFormFieldState extends FormFieldState<DateTime> {}
|
|||
/// Shows an [_InputDropdown] that'll trigger [DateField._selectDate] whenever the user
|
||||
/// clicks on it ! The date picker is **platform responsive** (ios date picker style for ios, ...)
|
||||
class DateField extends StatelessWidget {
|
||||
|
||||
/// Default constructor
|
||||
const DateField({
|
||||
@required this.onDateSelected,
|
||||
|
@ -155,9 +153,7 @@ class DateField extends StatelessWidget {
|
|||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
final DateTime _selectedDate = await showDatePicker(
|
||||
context: context,
|
||||
initialDatePickerMode: initialDatePickerMode,
|
||||
|
@ -183,9 +179,11 @@ class DateField extends StatelessWidget {
|
|||
label: text == null ? null : label,
|
||||
errorText: errorText,
|
||||
decoration: decoration,
|
||||
onPressed: enabled ? () {
|
||||
onPressed: enabled
|
||||
? () {
|
||||
_selectDate(context);
|
||||
} : null,
|
||||
}
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -197,16 +195,15 @@ class DateField extends StatelessWidget {
|
|||
/// It does not show any popup menu, it'll just trigger onPressed whenever the
|
||||
/// user does click on it !
|
||||
class _InputDropdown extends StatelessWidget {
|
||||
const _InputDropdown(
|
||||
{Key key,
|
||||
const _InputDropdown({
|
||||
Key key,
|
||||
@required this.text,
|
||||
this.label,
|
||||
this.decoration,
|
||||
this.textStyle,
|
||||
this.onPressed,
|
||||
this.errorText,
|
||||
}) :
|
||||
assert(text != null),
|
||||
}) : assert(text != null),
|
||||
super(key: key);
|
||||
|
||||
/// The label to display for the field (default is 'Select date')
|
||||
|
@ -235,9 +232,9 @@ class _InputDropdown extends StatelessWidget {
|
|||
inkwellBorderRadius = BorderRadius.circular(8);
|
||||
}
|
||||
|
||||
final InputDecoration effectiveDecoration = decoration?.copyWith(
|
||||
errorText: errorText
|
||||
) ?? InputDecoration(
|
||||
final InputDecoration effectiveDecoration =
|
||||
decoration?.copyWith(errorText: errorText) ??
|
||||
InputDecoration(
|
||||
labelText: label,
|
||||
errorText: errorText,
|
||||
suffixIcon: Icon(Icons.arrow_drop_down),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: date_field
|
||||
description: Contains DateField and DateFormField which allows the user to pick a DateTime from an input field!
|
||||
version: 0.2.1
|
||||
version: 0.2.2
|
||||
homepage: 'https://github.com/GaspardMerten/date_field'
|
||||
|
||||
environment:
|
||||
|
|
Loading…
Reference in a new issue