Skip to content

Issue in Date Answer Format #2

@Purus

Description

@Purus

For the below step there is an exception on the default value.

          QuestionStep(
            title: 'Your Birthday?',
            answerFormat: DateAnswerFormat(
              minDate: DateTime.now().subtract(const Duration(days: 365 * 70)),
              maxDate: DateTime.now().subtract(const Duration(days: 365 * 15)),
              defaultDate:
                  DateTime.now().subtract(const Duration(days: 365 * 20)),
            ),
          ),

Below is the exception. Does not make sense as I set the default date within the range.

The following assertion was thrown building DateAnswerView(dirty, dependencies: [_LocalizationsScope-[GlobalKey#9b781], _InheritedTheme], state: _DateAnswerViewState#9bd0a):
initialDate 2021-04-10 00:00:00.000 must be on or before lastDate 2006-04-14 00:00:00.000.
'package:flutter/src/material/calendar_date_picker.dart':
Failed assertion: line 116 pos 7: '!this.initialDate.isAfter(this.lastDate)'

The relevant error-causing widget was: 
  SurveyKit file:///D:/Flutter/club/lib/pages/survey/user_survey.dart:8:13
When the exception was thrown, this was the stack: 
#2      new CalendarDatePicker (package:flutter/src/material/calendar_date_picker.dart:116:7)
#3      _DateAnswerViewState._androidDatePicker (package:survey_kit/src/views/date_answer_view.dart:109:18)
#4      _DateAnswerViewState.build (package:survey_kit/src/views/date_answer_view.dart:73:32)
#5      StatefulElement.build (package:flutter/src/widgets/framework.dart:4612:27)
#6      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4495:15)
...
====================================================================================================

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions