DOBInputField constructor

DOBInputField({
  1. Key? key,
  2. DateTime? initialDate,
  3. required DateTime firstDate,
  4. required DateTime lastDate,
  5. bool showCursor = true,
  6. Radius? cursorRadius,
  7. double cursorWidth = 2.0,
  8. Color cursorColor = Colors.black,
  9. ValueChanged<DateTime>? onDateSubmitted,
  10. bool showLabel = false,
  11. DateFormatType dateFormatType = DateFormatType.DDMMYYYY,
  12. InputDecoration inputDecoration = const InputDecoration(border: OutlineInputBorder(borderSide: BorderSide.none), filled: true, fillColor: Colors.white, counterText: '', hintText: 'MM/DD/YYYY'),
  13. ValueChanged<DateTime>? onDateSaved,
  14. AutovalidateMode autovalidateMode = AutovalidateMode.onUserInteraction,
  15. TextAlign textAlign = TextAlign.left,
  16. SelectableDayPredicate? selectableDayPredicate,
  17. String? errorFormatText,
  18. String? errorInvalidText,
  19. String? fieldHintText,
  20. TextStyle? style,
  21. String? fieldLabelText,
  22. bool autofocus = false,
})

Implementation

DOBInputField({
  Key? key,
  DateTime? initialDate,
  required DateTime firstDate,
  required DateTime lastDate,
  this.showCursor = true,
  this.cursorRadius,
  this.cursorWidth = 2.0,
  this.cursorColor = Colors.black,
  this.onDateSubmitted,
  this.showLabel = false,
  this.dateFormatType = DateFormatType.DDMMYYYY,
  this.inputDecoration = const InputDecoration(
    border: OutlineInputBorder(
      borderSide: BorderSide.none,
    ),
    filled: true,
    fillColor: Colors.white,
    counterText: '',
    hintText: 'MM/DD/YYYY',
  ),
  this.onDateSaved,
  this.autovalidateMode = AutovalidateMode.onUserInteraction,
  this.textAlign = TextAlign.left,
  this.selectableDayPredicate,
  this.errorFormatText,
  this.errorInvalidText,
  this.fieldHintText,
  this.style,
  this.fieldLabelText,
  this.autofocus = false,
})  : assert(firstDate != null),
      assert(lastDate != null),
      assert(autofocus != null),
      initialDate =
          initialDate != null ? DateUtils.dateOnly(initialDate) : null,
      firstDate = DateUtils.dateOnly(firstDate),
      lastDate = DateUtils.dateOnly(lastDate),
      super(key: key) {
  assert(
    !this.lastDate.isBefore(this.firstDate),
    'lastDate ${this.lastDate} must be on or after firstDate ${this.firstDate}.',
  );
  assert(
    initialDate == null || !this.initialDate!.isBefore(this.firstDate),
    'initialDate ${this.initialDate} must be on or after firstDate ${this.firstDate}.',
  );
  assert(
    initialDate == null || !this.initialDate!.isAfter(this.lastDate),
    'initialDate ${this.initialDate} must be on or before lastDate ${this.lastDate}.',
  );
  assert(
    selectableDayPredicate == null ||
        initialDate == null ||
        selectableDayPredicate!(this.initialDate!),
    'Provided initialDate ${this.initialDate} must satisfy provided selectableDayPredicate.',
  );
  assert(
    selectableDayPredicate == null ||
        initialDate == null ||
        selectableDayPredicate!(this.initialDate!),
    'Provided initialDate ${this.initialDate} must satisfy provided selectableDayPredicate.',
  );
}