Describe the bug
When listening for a onPageChanged update from the calendar, the eventLoader function polls many unnecessary dates in an odd order. It will run through the correct dates first; e.g. when switching from Feb -> March, 2/25/2024 - 4/6/2024 as expected, then it will be called again, running through 2/25/2024 - 3/31/2024, with 1/31/2024, including all of February's dates for some reason.
To reproduce
Please include a short code sample that can be used to reproduce the problem.
Steps to reproduce the behavior:
See above
I have also tried removing the setState call within the onPageChanged function (as per the documentation), but to no avail.
Expected behavior
Run through the correct range, as defined above (1st of the month - last day of the month we are switching to with onPageChanged)
Screenshots
N/A
Output of flutter doctor
Paste the result of this command here.
Output
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.16.9, on Microsoft Windows [Version 10.0.19045.4046], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.6.1)
[√] Android Studio (version 2023.1)
[√] IntelliJ IDEA Community Edition (version 2023.1)
[√] VS Code (version 1.86.2)
[√] Connected device (4 available)
[√] Network resources
• No issues found!
Do you experience the same issue with example projects? eventLoader should be called only for the newly visible days.
You might have something going wrong in your onPageChanged callback.
Describe the bug When listening for a onPageChanged update from the calendar, the eventLoader function polls many unnecessary dates in an odd order. It will run through the correct dates first; e.g. when switching from Feb -> March, 2/25/2024 - 4/6/2024 as expected, then it will be called again, running through 2/25/2024 - 3/31/2024, with 1/31/2024, including all of February's dates for some reason.
To reproduce Please include a short code sample that can be used to reproduce the problem.
Code sample
eventLoader: (day) { List accounts = [];
accounts.addAll(LocalLedger.getExpensesByDay(day));
accounts.addAll(LocalLedger.getLiabilitiesByDay(day));
return accounts;
}
onPageChanged: (focusedDay) { setState(() { _selectedDay = focusedDay; widget.onPageChanged((DateTime(focusedDay.year, focusedDay.month, 1), DateTime(focusedDay.year, focusedDay.month+1, 0))); });
widget.onPageChanged: ((DateTime, DateTime) range) => print('test')
Steps to reproduce the behavior: See above I have also tried removing the setState call within the onPageChanged function (as per the documentation), but to no avail.
Expected behavior Run through the correct range, as defined above (1st of the month - last day of the month we are switching to with onPageChanged)
Screenshots N/A
Output of
flutter doctor
Paste the result of this command here.Output
Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.16.9, on Microsoft Windows [Version 10.0.19045.4046], locale en-US) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [√] Chrome - develop for the web [√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.6.1) [√] Android Studio (version 2023.1) [√] IntelliJ IDEA Community Edition (version 2023.1) [√] VS Code (version 1.86.2) [√] Connected device (4 available) [√] Network resources • No issues found!Additional context N/A