Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BasicDateTimeField allowing user to select time before initialTime. #120

Open
ghost opened this issue Sep 14, 2021 · 0 comments
Open

BasicDateTimeField allowing user to select time before initialTime. #120

ghost opened this issue Sep 14, 2021 · 0 comments

Comments

@ghost
Copy link

ghost commented Sep 14, 2021

This is the widget I'm working with:

DateTimeField(
  // Is disabled for iOS, only it's decoration is being used.
  enabled: platformIsAndroid,
  controller: _deadlineController,
  format: CreatePollModel.deadLineFormat,
  style: Properties.black16RegTextField,
  maxLines: 1,
  onShowPicker: (context, currentValue) async {
    final now = DateTime.now();
    final date = await showDatePicker(
      context: context,
      firstDate: now,
      initialDate: now,
      lastDate: widget.model.maxDate,
    );
    if (date != null) {
      final time = await showTimePicker(
        context: context,
        initialTime: TimeOfDay.fromDateTime(currentValue ?? now),
      );
      return DateTimeField.combine(date, time);
    } else {
      return currentValue;
    }
  },
  onFieldSubmitted: widget.model.updateDeadLine,
),

The calendar correctly disables the previous dates from DateTime.now() but when the user selects the current day, the time picker does not "remember" that it shouldn't allow to use an earlier time from the day.

Please confirm if I'm doing something wrong.

related #25 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants