buildInputDatePickerFormField method

  1. @protected
Widget buildInputDatePickerFormField(
  1. BuildParameters params
)

Implementation

@protected
Widget buildInputDatePickerFormField(BuildParameters params) {
  var alias = params.props["alias"] ?? params.id;
  DateTime? value;
  if (params.props["value"] == "now") {
    value = DateTime.now();
  } else {
    value = tryParseDateTime(params.props["value"]);
  }
  DateTime firstDate;
  if (params.props["firstDate"] == "now") {
    firstDate = DateTime.now();
  } else {
    firstDate = DateTime(1900);
    if (params.props["firstDate"] != null) {
      firstDate =
          parseDateTime(params.props["lastDate"], defaultValue: firstDate);
    }
  }
  DateTime lastDate;
  if (params.props["lastDate"] == "now") {
    lastDate = DateTime.now();
  } else {
    lastDate = DateTime(2100);
    if (params.props["lastDate"] != null) {
      lastDate =
          parseDateTime(params.props["lastDate"], defaultValue: lastDate);
    }
  }

  return InputDatePickerFormField(
    key: properties.getKey(params.id),
    initialDate: value,
    firstDate: firstDate,
    lastDate: lastDate,
    fieldHintText: params.props["hint"],
    fieldLabelText: params.props["label"],
    onDateSubmitted: (v) {},
    onDateSaved: (v) {
      if (alias != null) {
        params.state[alias] = v;
      }
    },
  );
}