From e1ddb337bd198c74ad5ea3b449326b57e31e6d1d Mon Sep 17 00:00:00 2001 From: Parth Baraiya Date: Fri, 24 Nov 2023 16:06:21 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Quick=20fixes=20before=20PR.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 9 ++- README.md | 28 ++++++-- example/lib/pages/create_event_page.dart | 2 +- example/lib/pages/day_view_page.dart | 4 +- example/lib/pages/event_details_page.dart | 4 +- example/lib/pages/home_page.dart | 2 +- example/lib/pages/month_view_page.dart | 4 +- example/lib/pages/week_view_page.dart | 7 +- example/lib/widgets/add_event_form.dart | 5 ++ example/lib/widgets/calendar_configs.dart | 4 +- example/lib/widgets/calendar_views.dart | 3 +- example/lib/widgets/custom_button.dart | 3 +- example/lib/widgets/date_time_selector.dart | 2 - example/lib/widgets/day_view_widget.dart | 7 +- example/lib/widgets/month_view_widget.dart | 4 +- example/lib/widgets/responsive_widget.dart | 4 +- example/lib/widgets/week_view_widget.dart | 2 +- example/pubspec.yaml | 2 +- lib/src/calendar_event_data.dart | 63 +++++++++++++++--- lib/src/components/_internal_components.dart | 1 + lib/src/day_view/_internal_day_view_page.dart | 5 +- lib/src/event_controller.dart | 64 +++++-------------- lib/src/extensions.dart | 1 + .../week_view/_internal_week_view_page.dart | 6 +- 24 files changed, 139 insertions(+), 97 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3742ad26..4cd10dec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# [1.0.5] (UnReleased)(https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/1.0.5) +# [1.0.5] (UnReleased) - Fixed issue related to auto scroll to initial duration for day view. [#269](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/269) @@ -11,6 +11,13 @@ feature added Support for changing the week day position(top/bottom) in weekView. [#283](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/283) - Adds new flag `includeEdges` in `EventArrangers`. [#290](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/pull/294) - Fixes null check exception while adding events. [#282](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/282) +- Added new method `update` to update the events in `EventController`. [#125](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/125) +- Adds new parameter `includeFullDayEvents` in `getEventsOnDay` to decide whether to include full-day events in the returned list or not. +- Adds getters `isRangingEvent` and `isFullDayEvent` in `CalendarEventData` to check if the event is a ranging event or a full-day event. +- Adds new method `occursOnDate` in `CalendarEventData` to check if the event occurs on the given date or not. +- Make `description` in `CalendarEventData` nullable. +- #### Deprecations + - Deprecate `events` getter in `EventController` and adds `allEvents` to replace it. # [1.0.4 - 9 Aug 2023](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/1.0.4) diff --git a/README.md b/README.md index 3a864ece..df79af43 100644 --- a/README.md +++ b/README.md @@ -226,12 +226,19 @@ assigned. Methods provided by `EventController` -| Name | Parameters | Description | -|----------------|---------------------------------------|------------------------------------------------------| -| add | CalendarEventData\ event | Adds one event in controller and rebuilds view. | -| addAll | List\\> events | Adds list of events in controller and rebuilds view. | -| remove | CalendarEventData\ event | Removes an event from controller and rebuilds view. | -| getEventsOnDay | DateTime date | Returns list of events on `date` | +| Name | Parameters | Description | +|-----------------|--------------------------------------------------------------|-----------------------------------------------------------| +| add | CalendarEventData\ event | Adds one event in controller and rebuilds view. | +| addAll | List\\> events | Adds list of events in controller and rebuilds view. | +| remove | CalendarEventData\ event | Removes an event from controller and rebuilds view. | +| removeAll | List\\> events | Removes all event defined in the list | +| removeWhere | TestPredicate\\> test | Removes all events for which test returns true. | +| update | CalendarEventData\ event, CalendarEventData\ updated | Updates event with updated event. | +| getFullDayEvent | DateTime date | Returns the list of full day events stored in controller | +| updateFilter | EventFilter\ newFilter | Updates the event filter of the controller. | +| getEventsOnDay | DateTime date | Returns list of events on `date` | + +Check [documentation](https://pub.dev/documentation/calendar_view/latest/calendar_view/EventController-class.html) for more info. ### Use of `GlobalKey` @@ -256,6 +263,9 @@ Methods defined by `MonthViewState` class: | jumpToMonth | DateTime month | Jumps to the page that has a calendar for month defined by `month` | | animateToMonth | DateTime month | Animate to the page that has a calendar for month defined by `month` | +Check [documentation](https://pub.dev/documentation/calendar_view/latest/calendar_view/MonthViewState-class.html) for more info. + + Methods defined by `DayViewState` class. | Name | Parameters | Description | @@ -270,6 +280,8 @@ Methods defined by `DayViewState` class. | animateToEvent | CalendarEventData event | Animates to the page where a given `event` is and then scrolls to make that `event` visible on the screen. | | jumpToEvent | CalendarEventData event | Jumps to the page where a given `event` is and then scrolls to make that `event` visible on the screen. | +Check [documentation](https://pub.dev/documentation/calendar_view/latest/calendar_view/DayViewState-class.html) for more info. + Methods defined by `WeekViewState` class. | Name | Parameters | Description | @@ -283,6 +295,8 @@ Methods defined by `WeekViewState` class. | animateToEvent | CalendarEventData event | Animates to the page where a given `event` is and then scrolls to make that `event` visible on the screen. | | jumpToEvent | CalendarEventData event | Jumps to the page where a given `event` is and then scrolls to make that `event` visible on the screen. | +Check [documentation](https://pub.dev/documentation/calendar_view/latest/calendar_view/WeekViewState-class.html) for more info. + ### Synchronize events between calendar views There are two ways to synchronize events between calendar views. @@ -353,7 +367,7 @@ copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE diff --git a/example/lib/pages/create_event_page.dart b/example/lib/pages/create_event_page.dart index 85bfb42f..3b8e2499 100644 --- a/example/lib/pages/create_event_page.dart +++ b/example/lib/pages/create_event_page.dart @@ -42,7 +42,7 @@ class CreateEventPage extends StatelessWidget { if (this.event != null) { CalendarControllerProvider.of(context) .controller - .updateEvent(this.event!, newEvent); + .update(this.event!, newEvent); } else { CalendarControllerProvider.of(context).controller.add(newEvent); } diff --git a/example/lib/pages/day_view_page.dart b/example/lib/pages/day_view_page.dart index f58e9be1..1a80aba2 100644 --- a/example/lib/pages/day_view_page.dart +++ b/example/lib/pages/day_view_page.dart @@ -1,6 +1,6 @@ -import 'package:example/enumerations.dart'; import 'package:flutter/material.dart'; +import '../enumerations.dart'; import '../extension.dart'; import '../widgets/day_view_widget.dart'; import '../widgets/responsive_widget.dart'; @@ -8,7 +8,7 @@ import 'create_event_page.dart'; import 'web/web_home_page.dart'; class DayViewPageDemo extends StatefulWidget { - const DayViewPageDemo({Key? key}) : super(key: key); + const DayViewPageDemo({super.key}); @override _DayViewPageDemoState createState() => _DayViewPageDemoState(); diff --git a/example/lib/pages/event_details_page.dart b/example/lib/pages/event_details_page.dart index b8b0052e..2785688d 100644 --- a/example/lib/pages/event_details_page.dart +++ b/example/lib/pages/event_details_page.dart @@ -1,13 +1,13 @@ import 'package:calendar_view/calendar_view.dart'; -import 'package:example/pages/create_event_page.dart'; import 'package:flutter/material.dart'; import '../extension.dart'; +import 'create_event_page.dart'; class DetailsPage extends StatelessWidget { final CalendarEventData event; - const DetailsPage({Key? key, required this.event}) : super(key: key); + const DetailsPage({super.key, required this.event}); @override Widget build(BuildContext context) { return Scaffold( diff --git a/example/lib/pages/home_page.dart b/example/lib/pages/home_page.dart index 894d1f76..85d8f05d 100644 --- a/example/lib/pages/home_page.dart +++ b/example/lib/pages/home_page.dart @@ -5,7 +5,7 @@ import 'mobile/mobile_home_page.dart'; import 'web/web_home_page.dart'; class HomePage extends StatelessWidget { - const HomePage({Key? key}) : super(key: key); + const HomePage({super.key}); @override Widget build(BuildContext context) { diff --git a/example/lib/pages/month_view_page.dart b/example/lib/pages/month_view_page.dart index 9cc77e88..9bd798c2 100644 --- a/example/lib/pages/month_view_page.dart +++ b/example/lib/pages/month_view_page.dart @@ -9,8 +9,8 @@ import 'web/web_home_page.dart'; class MonthViewPageDemo extends StatefulWidget { const MonthViewPageDemo({ - Key? key, - }) : super(key: key); + super.key, + }); @override _MonthViewPageDemoState createState() => _MonthViewPageDemoState(); diff --git a/example/lib/pages/week_view_page.dart b/example/lib/pages/week_view_page.dart index d177cdbd..3a183f5e 100644 --- a/example/lib/pages/week_view_page.dart +++ b/example/lib/pages/week_view_page.dart @@ -1,15 +1,14 @@ -import 'package:calendar_view/calendar_view.dart'; -import 'package:example/enumerations.dart'; -import 'package:example/widgets/responsive_widget.dart'; import 'package:flutter/material.dart'; +import '../enumerations.dart'; import '../extension.dart'; +import '../widgets/responsive_widget.dart'; import '../widgets/week_view_widget.dart'; import 'create_event_page.dart'; import 'web/web_home_page.dart'; class WeekViewDemo extends StatefulWidget { - const WeekViewDemo({Key? key}) : super(key: key); + const WeekViewDemo({super.key}); @override _WeekViewDemoState createState() => _WeekViewDemoState(); diff --git a/example/lib/widgets/add_event_form.dart b/example/lib/widgets/add_event_form.dart index 1dcba9d4..a34414ad 100644 --- a/example/lib/widgets/add_event_form.dart +++ b/example/lib/widgets/add_event_form.dart @@ -314,6 +314,11 @@ class _AddOrEditEventFormState extends State { _endDate = DateTime.now().withoutTime; _startTime = null; _endTime = null; + _color = Colors.blue; + + if (mounted) { + setState(() {}); + } } void _displayColorPicker() { diff --git a/example/lib/widgets/calendar_configs.dart b/example/lib/widgets/calendar_configs.dart index 31b0c327..9f976f88 100644 --- a/example/lib/widgets/calendar_configs.dart +++ b/example/lib/widgets/calendar_configs.dart @@ -11,10 +11,10 @@ class CalendarConfig extends StatelessWidget { final CalendarView currentView; const CalendarConfig({ - Key? key, + super.key, required this.onViewChange, this.currentView = CalendarView.month, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/example/lib/widgets/calendar_views.dart b/example/lib/widgets/calendar_views.dart index a07eaccd..28509775 100644 --- a/example/lib/widgets/calendar_views.dart +++ b/example/lib/widgets/calendar_views.dart @@ -11,8 +11,7 @@ import 'week_view_widget.dart'; class CalendarViews extends StatelessWidget { final CalendarView view; - const CalendarViews({Key? key, this.view = CalendarView.month}) - : super(key: key); + const CalendarViews({super.key, this.view = CalendarView.month}); final _breakPoint = 490.0; diff --git a/example/lib/widgets/custom_button.dart b/example/lib/widgets/custom_button.dart index bdfeb898..02a92a9b 100644 --- a/example/lib/widgets/custom_button.dart +++ b/example/lib/widgets/custom_button.dart @@ -6,8 +6,7 @@ class CustomButton extends StatelessWidget { final String title; final VoidCallback? onTap; - const CustomButton({Key? key, required this.title, this.onTap}) - : super(key: key); + const CustomButton({super.key, required this.title, this.onTap}); @override Widget build(BuildContext context) { diff --git a/example/lib/widgets/date_time_selector.dart b/example/lib/widgets/date_time_selector.dart index a6ee1800..008d5666 100644 --- a/example/lib/widgets/date_time_selector.dart +++ b/example/lib/widgets/date_time_selector.dart @@ -46,8 +46,6 @@ class DateTimeSelectorFormField extends StatefulWidget { } class _DateTimeSelectorFormFieldState extends State { - bool _isSelectorOpen = false; - late var _minimumDate = CalendarConstants.minDate.withoutTime; late var _textEditingController = diff --git a/example/lib/widgets/day_view_widget.dart b/example/lib/widgets/day_view_widget.dart index 819e212e..8a886327 100644 --- a/example/lib/widgets/day_view_widget.dart +++ b/example/lib/widgets/day_view_widget.dart @@ -1,16 +1,17 @@ import 'package:calendar_view/calendar_view.dart'; -import 'package:example/pages/event_details_page.dart'; import 'package:flutter/material.dart'; +import '../pages/event_details_page.dart'; + class DayViewWidget extends StatelessWidget { final GlobalKey? state; final double? width; const DayViewWidget({ - Key? key, + super.key, this.state, this.width, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/example/lib/widgets/month_view_widget.dart b/example/lib/widgets/month_view_widget.dart index fc41a432..9f287382 100644 --- a/example/lib/widgets/month_view_widget.dart +++ b/example/lib/widgets/month_view_widget.dart @@ -8,10 +8,10 @@ class MonthViewWidget extends StatelessWidget { final double? width; const MonthViewWidget({ - Key? key, + super.key, this.state, this.width, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/example/lib/widgets/responsive_widget.dart b/example/lib/widgets/responsive_widget.dart index d0467dcb..8c0984b0 100644 --- a/example/lib/widgets/responsive_widget.dart +++ b/example/lib/widgets/responsive_widget.dart @@ -9,12 +9,12 @@ class ResponsiveWidget extends StatelessWidget { final Widget mobileWidget; const ResponsiveWidget({ - Key? key, + super.key, this.width, this.breakPoint = BreakPoints.web, required this.webWidget, required this.mobileWidget, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/example/lib/widgets/week_view_widget.dart b/example/lib/widgets/week_view_widget.dart index 3dcc3435..adde1e00 100644 --- a/example/lib/widgets/week_view_widget.dart +++ b/example/lib/widgets/week_view_widget.dart @@ -7,7 +7,7 @@ class WeekViewWidget extends StatelessWidget { final GlobalKey? state; final double? width; - const WeekViewWidget({Key? key, this.state, this.width}) : super(key: key); + const WeekViewWidget({super.key, this.state, this.width}); @override Widget build(BuildContext context) { diff --git a/example/pubspec.yaml b/example/pubspec.yaml index e4b34e86..0a1fba67 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.18.6 <3.0.0" + sdk: ">=3.0.0 <4.0.0" flutter: ^3.3.10 dependencies: diff --git a/lib/src/calendar_event_data.dart b/lib/src/calendar_event_data.dart index 121afd70..bb06515d 100644 --- a/lib/src/calendar_event_data.dart +++ b/lib/src/calendar_event_data.dart @@ -4,10 +4,11 @@ import 'package:flutter/material.dart'; -import 'extensions.dart'; +import '../calendar_view.dart'; -/// Stores all the events on [date] @immutable + +/// {@macro calendar_event_data_doc} class CalendarEventData { /// Specifies date on which all these events are. final DateTime date; @@ -43,13 +44,10 @@ class CalendarEventData { /// Define style of description. final TextStyle? descriptionStyle; - /// Stores all the events on [date]. - /// - /// If [startTime] and [endTime] both are 0 or either of them is null, then - /// event will be considered a full day event. - /// - const CalendarEventData({ + /// {@macro calendar_event_data_doc} + CalendarEventData({ required this.title, + required DateTime date, this.description, this.event, this.color = Colors.blue, @@ -58,23 +56,43 @@ class CalendarEventData { this.titleStyle, this.descriptionStyle, DateTime? endDate, - required this.date, - }) : _endDate = endDate; + }) : _endDate = endDate?.withoutTime, + date = date.withoutTime; DateTime get endDate => _endDate ?? date; + /// If this flag returns true that means event is occurring on multiple + /// days and is not a full day event. + /// bool get isRangingEvent { final diff = endDate.withoutTime.difference(date.withoutTime).inDays; return diff > 0 && !isFullDayEvent; } + /// Returns if the events is full day event or not. + /// + /// If it returns true that means the events is full day. but also it can + /// span across multiple days. + /// bool get isFullDayEvent { return (startTime == null || endTime == null || (startTime!.isDayStart && endTime!.isDayStart)); } + /// Returns a boolean that defines whether current event is occurring on + /// [currentDate] or not. + /// + bool occursOnDate(DateTime currentDate) { + return currentDate == date || + currentDate == endDate || + (currentDate.isBefore(endDate.withoutTime) && + currentDate.isAfter(date.withoutTime)); + } + + /// Returns event data in [Map] format. + /// Map toJson() => { "date": date, "startTime": startTime, @@ -85,6 +103,9 @@ class CalendarEventData { "endDate": endDate, }; + /// Returns new object of [CalendarEventData] with the updated values defined + /// as the arguments. + /// CalendarEventData copyWith({ String? title, String? description, @@ -139,3 +160,25 @@ class CalendarEventData { @override int get hashCode => super.hashCode; } + +/// {@template calendar_event_data_doc} +/// Stores all the events on [date]. +/// +/// If [startTime] and [endTime] both are 0 or either of them is null, then +/// event will be considered a full day event. +/// +/// - [date] and [endDate] are used to define dates only. So, If you +/// are providing any time information with these two arguments, +/// it will be ignored. +/// +/// - [startTime] and [endTime] are used to define the time span of the event. +/// So, If you are providing any day information (year, month, day), it will +/// be ignored. It will also, consider only hour and minutes as time. So, +/// seconds, milliseconds and microseconds will be ignored as well. +/// +/// - [startTime] and [endTime] can no span more then one day. For example, +/// If start time is 11th Nov 11:30 PM and end time is 12th Nov 1:30 AM, it +/// will not be considered as valid time. Events with invalid time will throw +/// [AssertionError] in debug mode and will be ignored in release mode +/// in [DayView] and [WeekView]. +/// {@endtemplate} diff --git a/lib/src/components/_internal_components.dart b/lib/src/components/_internal_components.dart index b4d63695..f1658124 100644 --- a/lib/src/components/_internal_components.dart +++ b/lib/src/components/_internal_components.dart @@ -321,6 +321,7 @@ class EventGenerator extends StatelessWidget { @override Widget build(BuildContext context) { + // TODO: Use SizedBox If possible. return Container( height: height, width: width, diff --git a/lib/src/day_view/_internal_day_view_page.dart b/lib/src/day_view/_internal_day_view_page.dart index 00d32ccf..47c4fbc4 100644 --- a/lib/src/day_view/_internal_day_view_page.dart +++ b/lib/src/day_view/_internal_day_view_page.dart @@ -225,7 +225,10 @@ class InternalDayViewPage extends StatelessWidget { date: date, onTileTap: onTileTap, eventArranger: eventArranger, - events: controller.getEventsOnDay(date), + events: controller.getEventsOnDay( + date, + includeFullDayEvents: false, + ), heightPerMinute: heightPerMinute, eventTileBuilder: eventTileBuilder, scrollNotifier: scrollNotifier, diff --git a/lib/src/event_controller.dart b/lib/src/event_controller.dart index 1fbd6938..7de3a202 100644 --- a/lib/src/event_controller.dart +++ b/lib/src/event_controller.dart @@ -88,7 +88,7 @@ class EventController extends ChangeNotifier { /// If [event] is not found in the controller, it will add the [updated] /// event in the controller. /// - void updateEvent(CalendarEventData event, CalendarEventData updated) { + void update(CalendarEventData event, CalendarEventData updated) { _calendarData.updateEvent(event, updated); notifyListeners(); } @@ -124,13 +124,13 @@ class EventController extends ChangeNotifier { //ignore: deprecated_member_use_from_same_package if (_eventFilter != null) return _eventFilter!.call(date, this.events); - return _calendarData.getEventsOnDay(date, - includeFullDays: includeFullDayEvents); + return _calendarData.getEventsOnDay(date.withoutTime, + includeFullDayEvents: includeFullDayEvents); } /// Returns full day events on given day. List> getFullDayEvent(DateTime date) { - return _calendarData.getFullDayEvent(date); + return _calendarData.getFullDayEvent(date.withoutTime); } /// Updates the [eventFilter]. @@ -186,13 +186,18 @@ class CalendarData { UnmodifiableListView> get rangingEventList => UnmodifiableListView(_rangingEventList); - /// Stores all full day events(24hr event) + /// Stores all full day events(24hr event). + /// + /// This includes all full day events that are recurring day events as well. + /// + /// final _fullDayEventList = >[]; UnmodifiableListView> get fullDayEventList => UnmodifiableListView(_fullDayEventList); //#region Data Manipulation Methods void addFullDayEvent(CalendarEventData event) { + // TODO: add separate logic for adding full day event and ranging event. _fullDayEventList.addEventInSortedManner(event); _eventList.add(event); } @@ -203,7 +208,7 @@ class CalendarData { } void addSingleDayEvent(CalendarEventData event) { - final date = event.date.withoutTime; + final date = event.date; if (_singleDayEvents[date] == null) { _singleDayEvents.addAll({ @@ -245,7 +250,7 @@ class CalendarData { } void removeSingleDayEvent(CalendarEventData event) { - if (_singleDayEvents[event.date.withoutTime]?.remove(event) ?? false) { + if (_singleDayEvents[event.date]?.remove(event) ?? false) { _eventList.remove(event); } } @@ -286,7 +291,7 @@ class CalendarData { //#region Data Fetch Methods List> getEventsOnDay(DateTime date, - {bool includeFullDays = true}) { + {bool includeFullDayEvents = true}) { final events = >[]; if (_singleDayEvents[date] != null) { @@ -294,15 +299,12 @@ class CalendarData { } for (final rangingEvent in _rangingEventList) { - if (date == rangingEvent.date || - date == rangingEvent.endDate || - (date.isBefore(rangingEvent.endDate) && - date.isAfter(rangingEvent.date))) { + if (rangingEvent.occursOnDate(date)) { events.add(rangingEvent); } } - if (includeFullDays) { + if (includeFullDayEvents) { events.addAll(getFullDayEvent(date)); } @@ -312,45 +314,13 @@ class CalendarData { /// Returns full day events on given day. List> getFullDayEvent(DateTime date) { final events = >[]; + for (final event in fullDayEventList) { - if (date.difference(event.date).inDays >= 0 && - event.endDate.difference(date).inDays > 0) { + if (event.occursOnDate(date)) { events.add(event); } } return events; } //#endregion - - //#region Private Methods - void _addEvent(CalendarEventData event) { - assert(event.endDate.difference(event.date).inDays >= 0, - 'The end date must be greater or equal to the start date'); - if (_calendarData.eventList.contains(event)) return; - if (event.endDate.difference(event.date).inDays > 0) { - if (event.startTime == null || - event.endTime == null || - (event.startTime!.isDayStart && event.endTime!.isDayStart)) { - _calendarData.fullDayEventList.addEventInSortedManner(event); - } else { - _calendarData.rangingEventList.addEventInSortedManner(event); - } - } else { - final date = event.date.withoutTime; - - if (_calendarData.events[date] == null) { - _calendarData.events.addAll({ - date: [event], - }); - } else { - _calendarData.events[date]!.addEventInSortedManner(event); - } - } - - _calendarData.eventList.add(event); - - notifyListeners(); - } - -//#endregion } diff --git a/lib/src/extensions.dart b/lib/src/extensions.dart index e97c842b..b26c67da 100644 --- a/lib/src/extensions.dart +++ b/lib/src/extensions.dart @@ -168,6 +168,7 @@ extension MinutesExtension on MinuteSlotSize { extension MyList on List { // Below function will add the new event in sorted manner(startTimeWise) in // the existing list of CalendarEventData. + void addEventInSortedManner(CalendarEventData event) { var addIndex = -1; diff --git a/lib/src/week_view/_internal_week_view_page.dart b/lib/src/week_view/_internal_week_view_page.dart index 1cd2466e..97287571 100644 --- a/lib/src/week_view/_internal_week_view_page.dart +++ b/lib/src/week_view/_internal_week_view_page.dart @@ -336,8 +336,10 @@ class InternalWeekViewPage extends StatelessWidget { eventArranger: eventArranger, eventTileBuilder: eventTileBuilder, scrollNotifier: scrollConfiguration, - events: controller - .getEventsOnDay(filteredDates[index]), + events: controller.getEventsOnDay( + filteredDates[index], + includeFullDayEvents: false, + ), heightPerMinute: heightPerMinute, ), ],