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

minSelectedDatem maxSelectedDate after updating State #223

Closed
Dalimar95 opened this issue Jun 22, 2020 · 6 comments
Closed

minSelectedDatem maxSelectedDate after updating State #223

Dalimar95 opened this issue Jun 22, 2020 · 6 comments

Comments

@Dalimar95
Copy link

Version of flutter_calendar_carousel

1.4.12

Expected behavior

minSelectedDate,maxSelectedDate update after setState

Actual behavior

minSelectedDate,maxSelectedDate doesn't update after changing the dates in setState

flutter doctor result (run flutter doctor in terminal)

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 1.20.0-1.0.pre.132, on Microsoft Windows [Version 10.0.18363.900], locale en-GB)

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Android Studio (version 3.5)
[√] VS Code (version 1.46.1)
[√] Connected device (1 available)

• No issues found!

Steps to reproduce the behavior

Update state and change Dates Passed to these variables

@bradleybeighton
Copy link

@Dalimar95 Has there been a resolution or workaround on this? I am experiencing the exact same issue. If the maxSekectedDate has increased the calendar doesn't take it into consideration.

@Dalimar95
Copy link
Author

@Dalimar95 Has there been a resolution or workaround on this? I am experiencing the exact same issue. If the maxSekectedDate has increased the calendar doesn't take it into consideration.

Hello Bradley i don't have access currently to pc so cannot give you exact work around , but you need to edit the. Dart file from this extension. Because its sets inside init state values of start and end date, you need copy that code to build section.

@Arun1811
Copy link

Arun1811 commented Aug 5, 2020

@Dalimar95 Has there been a resolution or workaround on this? I am experiencing the exact same issue. If the maxSekectedDate has increased the calendar doesn't take it into consideration.

Hello Bradley i don't have access currently to pc so cannot give you exact work around , but you need to edit the. Dart file from this extension. Because its sets inside init state values of start and end date, you need copy that code to build section.

Can you send me the updated code for this?

@Dimolll
Copy link

Dimolll commented Aug 23, 2020

I have the same issue
@Dalimar95 or @Arun1811 can u help me, please?
Can you send me the updated code?

@Arun1811
Copy link

Arun1811 commented Aug 25, 2020

I have the same issue
@Dalimar95 or @Arun1811 can u help me, please?
Can you send me the updated code?

Hi Dimoll

Change minDate to widget.minSelectedDate in flutter_calendar_carousel.dart

@OverRide
void didUpdateWidget(CalendarCarousel oldWidget) {

if (widget.targetDateTime != null && widget.targetDateTime != _targetDate) {
  DateTime targetDate = widget.targetDateTime;
  if (widget.targetDateTime.difference(widget.minSelectedDate).inDays < 0) {
    targetDate = widget.minSelectedDate;
  } else if (widget.targetDateTime.difference(maxDate).inDays > 0) {
    targetDate = maxDate;
  }
  int _page = this._pageNum;
  if (widget.weekFormat) {
    targetDate = _firstDayOfWeek(targetDate);
    for (int _cnt = 0;
        0 >
            widget.minSelectedDate
                .add(Duration(days: 7 * _cnt))
                .difference(targetDate)
                .inDays;
        _cnt++) {
      _page = _cnt + 1;
    }
  } else {
    for (int _cnt = 0;
        0 >
            DateTime(
              widget.minSelectedDate.year,
              widget.minSelectedDate.month + _cnt,
            )
                .difference(DateTime(targetDate.year, targetDate.month))
                .inDays;
        _cnt++) {
      _page = _cnt + 1;
    }
  }

  _setDate(_page);
}

super.didUpdateWidget(oldWidget);

}

@github-actions
Copy link

This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.

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

No branches or pull requests

4 participants