table_calendar
table_calendar copied to clipboard
The Horizontal swipe is not working on Desktop and Web.
Describe the bug The horizontal swipe is not working on the Web and Desktop, I've set the calendar format to weekly. But I'm not able to scroll to next or previous weeks, Whereas the same is working fine on the android as well on the IOS device.
To reproduce Here's the code that I've written.
`TableCalendar(
firstDay: kFirstDay,
lastDay: kLastDay,
focusedDay: _focusedDay,
calendarFormat: _calendarFormat,
weekNumbersVisible: false,
weekendDays: const [DateTime.saturday, DateTime.sunday],
startingDayOfWeek: StartingDayOfWeek.monday,
pageJumpingEnabled: true,
pageAnimationEnabled: true,
pageAnimationCurve: Curves.easeIn,
pageAnimationDuration: const Duration(milliseconds: 500),
headerVisible: false,
availableGestures: AvailableGestures.horizontalSwipe,
daysOfWeekStyle: DaysOfWeekStyle(
weekdayStyle: AppTextStyles.kNunitoBold13(color: AppColors.kcBlack),
weekendStyle: AppTextStyles.kNunitoBold13(color: AppColors.kcBlack),
),
selectedDayPredicate: (day) {
// Use `selectedDayPredicate` to determine which day is currently selected.
// If this returns true, then `day` will be marked as selected.
// Using `isSameDay` is recommended to disregard
// the time-part of compared DateTime objects.
return isSameDay(_selectedDay, day);
},
onDaySelected: (selectedDay, focusedDay) {
if (!isSameDay(_selectedDay, selectedDay)) {
// Call `setState()` when updating the selected day
setState(() {
_selectedDay = selectedDay;
_focusedDay = focusedDay;
});
}
},
onPageChanged: (focusedDay) {
// No need to call `setState()` here
_focusedDay = focusedDay;
},
rowHeight: 60.0,
calendarBuilders: CalendarBuilders(
defaultBuilder: (BuildContext context, DateTime selectedDate,
DateTime focusedDate) {
return CalendarDefaultBuilderWidget(selectedDate: selectedDate);
},
dowBuilder: (BuildContext context, DateTime date) {},
todayBuilder: (BuildContext context, DateTime selectedDate,
DateTime focusedDate) {
return CalendarTodayBuilderWidget(
selectedDate: selectedDate,
);
},
selectedBuilder: (BuildContext context, DateTime selectedDate,
DateTime focusedDate) {
return CalendarSelectedBuilderWidget(
selectedDate: selectedDate,
);
},
),
);`
</summary>
// Using `isSameDay` is recommended to disregard
// the time-part of compared DateTime objects.
return isSameDay(_selectedDay, day);
},
onDaySelected: (selectedDay, focusedDay) {
if (!isSameDay(_selectedDay, selectedDay)) {
// Call `setState()` when updating the selected day
setState(() {
_selectedDay = selectedDay;
_focusedDay = focusedDay;
});
}
},
onPageChanged: (focusedDay) {
// No need to call `setState()` here
_focusedDay = focusedDay;
},
rowHeight: 60.0,
calendarBuilders: CalendarBuilders(
defaultBuilder: (BuildContext context, DateTime selectedDate,
DateTime focusedDate) {
return CalendarDefaultBuilderWidget(selectedDate: selectedDate);
},
dowBuilder: (BuildContext context, DateTime date) {},
todayBuilder: (BuildContext context, DateTime selectedDate,
DateTime focusedDate) {
return CalendarTodayBuilderWidget(
selectedDate: selectedDate,
);
},
selectedBuilder: (BuildContext context, DateTime selectedDate,
DateTime focusedDate) {
return CalendarSelectedBuilderWidget(
selectedDate: selectedDate,
);
},
),
);`
</summary>
Steps to reproduce the behavior:
- Add the table_calendar package latest version.
- Implement a calendar in your app.
- Try to swipe to the next or previous week on the desktop or web.
Expected behavior The scroll should have worked as expected.
Screenshots If applicable, add screenshots to help explain your problem.
Output of flutter doctor
Paste the result of this command here.
```
[✓] Flutter (Channel stable, 3.7.0, on macOS 13.0 22A380 darwin-arm64, locale en-IN)
• Flutter version 3.7.0 on channel stable at /Users/shiv/FlutterDev/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision b06b8b2710 (11 days ago), 2023-01-23 16:55:55 -0800
• Engine revision b24591ed32
• Dart version 2.19.0
• DevTools version 2.20.1
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at /Users/shiv/Library/Android/sdk
• Platform android-33, build-tools 33.0.1
• Java binary at: /Users/shiv/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9123335/Android
Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14C18
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.3)
• Android Studio at /Users/shiv/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9123335/Android
Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
[!] Android Studio (version 2022.1)
• Android Studio at /Users/shiv/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9477386/Android
Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
✗ Unable to find bundled Java version.
• Try updating or re-installing Android Studio.
[✓] VS Code (version 1.74.3)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.58.0
[✓] Connected device (3 available)
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 12 (API 31) (emulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.0 22A380 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.119
[✓] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 1 category.
</summary>
</details>
**Additional context**
Add any other context about the problem here.
</summary>
</details>
**Additional context**
Add any other context about the problem here.
@mshivkumar Starting with Flutter 2.5.0, mouse drag scrolling is disabled by default.
Therefore, you must create and use the MyCustomScrollBehavior class by referring to the following link. https://docs.flutter.dev/release/breaking-changes/default-scroll-behavior-drag
If you set a MyCustomScrollBehavior instance to a ScrollConfiguration that wraps TableCalendar, swiping should work.
Yep, that's the idea. Closing as duplicate of #739