SILDatePickerField class

SILDatePickerField customized for date selection. Example

SILDatePickerField(
  context: context,
  allowCurrentYear: true,
  labelText: 'Diagnosis date',
  hintText: 'Select Diagnosis date',
  controller: diagnosisDateController,
  keyboardType: TextInputType.dateTime,
  onChanged: (dynamic value) {
    <do-something-awesome-here>
  },
  validator: (dynamic value) {
  if (value.isEmpty || value == null) {
  return 'Please select diagnosis date';
  }
  return null;
  },
  onSaved: (dynamic value) {
    <do-something-awesome-here>
  },
),
  • This widget used an AbsorbPointer widget so as to make it easier to access when doing hit testing
  • This widget also wraps the SILFormTextField() widget above so that the selector can also act as an input

The properties in this widget are the normal material date picker fields with a few tweaks and customizations namely:

  1. allowCurrentYear allows the date picker widget to alow dates to include the current year that can be gotten from DateTime().now.year
  2. allowFutureYears allows the date picker to accept date selection of future dates
  3. allowEligibleDate - allows selection of dates up to the eligible year which is defined in lib/shared/constants/date_time/date_time_constants.dart
Inheritance

Constructors

SILDatePickerField({required TextEditingController controller, FormFieldSetter<String>? onChanged, Key? gestureDateKey, Key? textFieldDateKey, FormFieldSetter<String>? onSaved, String? labelText, String? hintText, FocusNode? focusNode, TextInputType? keyboardType, FormFieldValidator<String>? validator, Icon? suffixIcon, bool? enabled, bool allowCurrentYear = false, bool allowFutureYears = false, bool allowEligibleDate = false, DateTime? customEligibleYear})
To set the initial value of the field, set the text property of the controller. E.g:
const

Properties

allowCurrentYear bool
final
allowEligibleDate bool
final
allowFutureYears bool
final
controller TextEditingController
final
customEligibleYear DateTime?
final
enabled bool?
final
focusNode FocusNode?
final
gestureDateKey Key?
final
hashCode int
The hash code for this object.
no setterinherited
hintText String?
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
keyboardType TextInputType?
final
labelText String?
final
onChanged FormFieldSetter<String>?
final
onSaved FormFieldSetter<String>?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
suffixIcon Icon?
final
textFieldDateKey Key?
final
validator FormFieldValidator<String>?
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
getLastDate() DateTime
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited