Giter Site home page Giter Site logo

simformsolutionspvtltd / flutter_calendar_view Goto Github PK

View Code? Open in Web Editor NEW
379.0 6.0 222.0 9.56 MB

A Flutter package allows you to easily implement all calendar UI and calendar event functionality. ๐Ÿ‘Œ๐Ÿ”๐ŸŽ‰

Home Page: https://pub.dev/packages/calendar_view

License: MIT License

Kotlin 0.04% Swift 0.30% Objective-C 0.01% Dart 86.77% HTML 0.45% CMake 4.24% C++ 7.14% C 0.24% Ruby 0.80%
flutter dart calendar package plugin widget

flutter_calendar_view's Introduction

Plugin Banner

calendar_view

Build calendar_view

A Flutter package allows you to easily implement all calendar UI and calendar event functionality.

For web demo visit Calendar View Example.

Preview

Preview

Installing

  1. Add dependencies to pubspec.yaml

    Get the latest version in the 'Installing' tab on pub.dev

    dependencies:
        calendar_view: <latest-version>
  2. Run pub get.

    flutter pub get
  3. Import package.

    import 'package:calendar_view/calendar_view.dart';

Implementation

  1. Wrap MaterialApp with CalendarControllerProvider and assign EventController to it.

    CalendarControllerProvider(
        controller: EventController(),
        child: MaterialApp(
            // Your initialization for material app.
        ),
    )
  2. Add calendar views.

    For Month View

    Scaffold(
        body: MonthView(),
    );

    For Day View

    Scaffold(
        body: DayView(),
    );

    For Week view

    Scaffold(
        body: WeekView(),
    );

    For more info on properties visit documentation .

  3. Use controller to add or remove events.

    To Add event:

    final event = CalendarEventData(
        date: DateTime(2021, 8, 10),
        event: "Event 1",
    );
    
    CalendarControllerProvider.of(context).controller.add(event);

    To Add events in range of dates:

    final event = CalendarEventData(
            date: DateTime(2021, 8, 10),
            endDate: DateTime(2021,8,15),
            event: "Event 1",
        );
    
        CalendarControllerProvider.of(context).controller.add(event);

    To Remove event:

    CalendarControllerProvider.of(context).controller.remove(event);

    As soon as you add or remove events from the controller, it will automatically update the calendar view assigned to that controller. See, Use of EventController for more info

  4. Use GlobalKey to change the page or jump to a specific page or date. See, Use of GlobalKey for more info.

More on the calendar view

Optional configurations/parameters in Calendar view

For month view

MonthView(
    controller: EventController(),
    // to provide custom UI for month cells.
    cellBuilder: (date, events, isToday, isInMonth) {
        // Return your widget to display as month cell.
        return Container();
    },
    minMonth: DateTime(1990),
    maxMonth: DateTime(2050),
    initialMonth: DateTime(2021),
    cellAspectRatio: 1,
    onPageChange: (date, pageIndex) => print("$date, $pageIndex"),
    onCellTap: (events, date) {
      // Implement callback when user taps on a cell.
      print(events);
    },
    startDay: WeekDays.sunday, // To change the first day of the week.
    // This callback will only work if cellBuilder is null.
    onEventTap: (event, date) => print(event),
    onEventDoubleTap: (events, date) => print(events),
    onEventLongTap: (event, date) => print(event),
    onDateLongPress: (date) => print(date),
    headerBuilder: MonthHeader.hidden, // To hide month header
    showWeekTileBorder: false, // To show or hide header border
    hideDaysNotInMonth: true, // To hide days or cell that are not in current month
);

For day view

DayView(
    controller: EventController(),
    eventTileBuilder: (date, events, boundry, start, end) {
        // Return your widget to display as event tile.
        return Container();
    },
    fullDayEventBuilder: (events, date) {
        // Return your widget to display full day event view.
        return Container();
    },
    showVerticalLine: true, // To display live time line in day view.
    showLiveTimeLineInAllDays: true, // To display live time line in all pages in day view.
    minDay: DateTime(1990),
    maxDay: DateTime(2050),
    initialDay: DateTime(2021),
    heightPerMinute: 1, // height occupied by 1 minute time span.
    eventArranger: SideEventArranger(), // To define how simultaneous events will be arranged.
    onEventTap: (events, date) => print(events),
    onEventDoubleTap: (events, date) => print(events),
    onEventLongTap: (events, date) => print(events),
    onDateLongPress: (date) => print(date),
    startHour: 5 // To set the first hour displayed (ex: 05:00)
    endHour:20, // To set the end hour displayed
    hourLinePainter: (lineColor, lineHeight, offset, minuteHeight, showVerticalLine, verticalLineOffset) {
        return //Your custom painter.
    },
    dayTitleBuilder: DayHeader.hidden, // To Hide day header
    keepScrollOffset: true, // To maintain scroll offset when the page changes
);

For week view

WeekView(
    controller: EventController(),
    eventTileBuilder: (date, events, boundry, start, end) {
      // Return your widget to display as event tile.
      return Container();
    },
    fullDayEventBuilder: (events, date) {
      // Return your widget to display full day event view.
      return Container();
    },
    showLiveTimeLineInAllDays: true, // To display live time line in all pages in week view.
    width: 400, // width of week view.
    minDay: DateTime(1990),
    maxDay: DateTime(2050),
    initialDay: DateTime(2021),
    heightPerMinute: 1, // height occupied by 1 minute time span.
    eventArranger: SideEventArranger(), // To define how simultaneous events will be arranged.
    onEventTap: (events, date) => print(events),
    onEventDoubleTap: (events, date) => print(events),
    onDateLongPress: (date) => print(date),
    startDay: WeekDays.sunday, // To change the first day of the week.
    startHour: 5, // To set the first hour displayed (ex: 05:00)
    endHour:20, // To set the end hour displayed
    showVerticalLines: false, // Show the vertical line between days.
    hourLinePainter: (lineColor, lineHeight, offset, minuteHeight, showVerticalLine, verticalLineOffset) {
        return //Your custom painter.
    },
    weekPageHeaderBuilder: WeekHeader.hidden, // To hide week header
    fullDayHeaderTitle: 'All day', // To set full day events header title
    fullDayHeaderTextConfig: FullDayHeaderTextConfig(
      textAlign: TextAlign.center,
      textOverflow: TextOverflow.ellipsis,
      maxLines: 2,
    ), // To set full day events header text config
    keepScrollOffset: true, // To maintain scroll offset when the page changes
);

To see the list of all parameters and detailed description of parameters visit documentation .

Use of EventController

EventController is used to add or remove events from the calendar view. When we add or remove events from the controller, it will automatically update all the views to which this controller is assigned.

Methods provided by EventController

Name Parameters Description
add CalendarEventData<T> event Adds one event in controller and rebuilds view.
addAll List<CalendarEventData<T>> events Adds list of events in controller and rebuilds view.
remove CalendarEventData<T> event Removes an event from controller and rebuilds view.
removeAll List<CalendarEventData<T>> events Removes all event defined in the list
removeWhere TestPredicate<CalendarEventData<T>> test Removes all events for which test returns true.
update CalendarEventData<T> event, CalendarEventData<T> updated Updates event with updated event.
getFullDayEvent DateTime date Returns the list of full day events stored in controller
updateFilter EventFilter<T> newFilter Updates the event filter of the controller.
getEventsOnDay DateTime date Returns list of events on date

Check documentation for more info.

Use of GlobalKey

User needs to define global keys to access functionalities like changing a page or jump to a specific page or date. Users can also access the controller assigned to respected view using the global key.

By assigning global keys to calendar views you can access methods and fields defined by state class of respected views.

Methods defined by MonthViewState class:

Name Parameters Description
nextPage none Jumps to next page.
previousPage none Jumps to the previous page.
jumpToPage int page Jumps to page index defined by page.
animateToPage int page Animate to page index defined by page.
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 for more info.

Methods defined by DayViewState class.

Name Parameters Description
nextPage none Jumps to next page.
previousPage none Jumps to the previous page.
jumpToPage int page Jumps to page index defined by page.
animateToPage int page Animate to page index defined by page.
jumpToDate DateTime date Jumps to the page that has a calendar for month defined by date
animateToDate DateTime date Animate to the page that has a calendar for month defined by date
animateToDuration Duration duration Animate to the duration
from where we want start the day DayView
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 for more info.

Methods defined by WeekViewState class.

Name Parameters Description
nextPage none Jumps to next page.
previousPage none Jumps to the previous page.
jumpToPage int page Jumps to page index defined by page.
animateToPage int page Animate to page index defined by page.
jumpToWeek DateTime week Jumps to the page that has a calendar for month defined by week
animateToWeek DateTime week Animate to the page that has a calendar for month defined by week
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 for more info.

Synchronize events between calendar views

There are two ways to synchronize events between calendar views.

  1. Provide the same controller object to all calendar views used in the project.
  2. Wrap MaterialApp with CalendarControllerProvider and provide controller as argument as defined in Implementation.

Show only working days in WeekView.

You can configure week view such that it displays only specific days. ex,

WeekView(
  weekDays: [
    WeekDays.monday,
    WeekDays.tuesday,
    WeekDays.wednesday,
    WeekDays.thursday,
    WeekDays.friday,
  ],
);

Above code will create WeekView with only five days, from monday to friday.

Main Contributors


Vatsal Tanna

Sanket Kachhela

Parth Baraiya

Ujas Majithiya

Ankit Panchal

Mehul Kabaria

Faiyaz Shaikh

Dhaval Kansara

Apurva Kanthraviya

Awesome Mobile Libraries

License

MIT License

Copyright (c) 2021 Simform Solutions

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
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 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
SOFTWARE.

flutter_calendar_view's People

Contributors

ahmetakil avatar alexandremaul avatar apurva010 avatar b-scharbau avatar devyankshaw avatar dhavalrkansara avatar drunkendaddy avatar dumazy avatar faiyaz-shaikh avatar felangel avatar freyien avatar jaiminrana05 avatar llucie avatar martimtsilva avatar mataai avatar mehulkk avatar mobile-simformsolutions avatar parthbaraiya avatar porum avatar prbaraiya avatar ravilsimform avatar rmpt avatar rohitbhoite avatar shwetachauhan18 avatar ujas-m-simformsolutions avatar werner-scholtz avatar yellowkitkat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

flutter_calendar_view's Issues

Next month is wrong when page changes

Months with 31 days are buggy when pages change. For example, today: 31 March 2022, when I change the month page (in MonthView) the view jumps to 2022 May.

To reproduce the bug, you can simply use a mobile phone and change the current system date to 31 March (or any other months with 31 days) and try to swipe to change page.

Weekview shows multi day events incorrect

I have an event created for multiple days with for example starttime 1pm on Saturday and endtime 2pm on the Monday after.

Code:

(
          event: booking,
          title: StringExtensions.toInitials(
            booking.user!.firstName,
            booking.user!.lastName,
          ),
          date: booking.startDateTime,
          startTime: booking.startDateTime,
          endTime: booking.endDateTime,
          endDate: booking.endDateTime,
          color: Color.fromARGB(255, 227, 83, 76),
)

It shows up like this:
image
image

What am I missing?

Scroll to index/liveTime

Hi, i've ben testing your library on my project.
I didn't found any way to scroll to an event index or liveTimeIndicator, is this possible?

[BUG] Duplicate item in cells while adding events in the same session

First thanks for the package.

I faced a duplicate issue on my project and then I tested your code and it happen for 100%.

USE CASE : I simply add events on a common date and the last event is duplicated in cell :

Capture dโ€™eฬcran 2022-04-16 aฬ€ 15 34 05

The duplicate is visible only when a previous event is already present in the cell -> Bike task is alone only on the 20 and Swim only on 22-23
More events I add more it's duplicated x2, x3...

I checked current issue but nothing found related to this,
How can we solve this ?

Is there support for locale?

Hi, I liked a lot this package, but I wasn't able to find a way to change locale.
is there any planning to support?

Thanks

Change starting hour in day view

Apologies if this has been requested previously, but is it possible to change the start time in day view from 1am to something else?
Screen Shot 2022-08-31 at 9 33 38 AM

Notification

Thanks for this beautiful package, Just got to know of it today.

Please does the package support notification, let's say before an event date, you it will show a notification?

WeekDayTile causes RenderFlex-Overflow

I am using calendar_view (monthView) in a flutter web-project. Resizing the calendar_view works alright, except for the week-day-row.

When we reduce the screensize the weekDay-tiles are not resized (they keep the width with which they were initialized once), which creates a Renderflex-Overflow on the right side.

Bildschirmfoto vom 2022-02-23 14-27-56

DayView EventBuilder doesn't work

Eventbuilder for day view doesn't function

Doesn't call any function in it and is not returning any widget;

Tried putting a print statement in it too, still doesn't work

support Jalali Date

i can give you useful data for add Jalali date to calendar you can use this package for convert Gregorian to Jalali date https://pub.dev/packages/shamsi_date
and this package for convert English numbers to Persian numbers [https://pub.dev/packages/shamsi_date]
and then make this calendar AMAZING!

WeekView shows only 1 event in a day

Hi,
I have encountered an issue with the WeekView events.
My WeekView controllers get a list of CalendarEventData that contain a couple of events in the same date, but the view shows only the first event on each day.

here is my code -
(_appointments it is the list of CalendarEventData)

@OverRide
Widget build(BuildContext context) {
return
WeekView(
controller: CalendarControllerProvider.of(context).controller..addAll(_appointments), //EventController(),
showLiveTimeLineInAllDays: true,
width: MediaQuery.of(context).size.width,
minDay: DateTime(2000),
maxDay: DateTime(2050),
initialDay: DateTime.now(),
heightPerMinute: 1,
eventArranger: SideEventArranger(),
onEventTap: (events, date) => print(events),
onDateLongPress: (date) => print(date),
startDay: WeekDays.sunday,
);
}

any help?

Change amount of rows (height) of month view.

Hello! I have implemented a month view and the available space is not the full screen. Therefore, the month view contains six rows (weeks) which scroll up and down with the cells having a fixed height. I do not want this, I would prefer:
Setting an arbitrary height of the month view (for example using an expanded widget), and for the cells to adjust their heigh (aspect ratio) appropriately so there never is scrolling. Or the option to have only 5 weeks displayed, but still the height of the cells should fix neatly, without the need to scroll up or down the month view. Thanks!

Bug Week View. Today 10pm to tommorw 8am event will trhow an error

_calendarWeekEventList.add(CalendarEventData( date: DateTime(2022, 08, 14, 20, 0), startTime: DateTime(2022, 08, 14, 20, 0), endTime: DateTime(2022, 08, 15, 8, 23), endDate: DateTime(2022, 08, 15, 8, 23), title: '${DateFormat.jm().format(_startDate)} ' '- ${DateFormat.jm().format(_endDate)} ' '\n${_provider.name}', event: _event.toJson(), description: _event.$id, color: colorFromString(_provider.color), ));

Error Message:
startDate must be less than endDate.
This error occurs when you does not provide startDate or endDate in CalendarEventDate or provided endDate occurs before startDate.
'package:calendar_view/src/event_arrangers/side_event_arranger.dart':
Failed assertion: line 130 pos 11: '!(endTime.getTotalMinutes <= startTime.getTotalMinutes)'

please help

on my calendar i just need these little arrows to select the weeks, i would like to remove the date information from the center and change the color from blue to white, could you explain to me how to do this? I tried but I couldn't
Sem tรญtulo

i try this but i recive this error

โ•โ•โ•โ•โ•โ•โ•โ• Exception caught by gesture โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
The following assertion was thrown while handling a gesture:
PageController.page cannot be accessed before a PageView is built with it.
'package:flutter/src/widgets/page_view.dart':
package:flutter/โ€ฆ/widgets/page_view.dart:1
Failed assertion: line 172 pos 7: 'positions.isNotEmpty'

_AssertionError ('package:flutter/src/widgets/page_view.dart': Failed assertion: line 172 pos 7: 'positions.isNotEmpty': PageController.page cannot be accessed before a PageView is built with it.)

try

weekPageHeaderBuilder: (DateTime startDate, DateTime endDate) {
        return Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            IconButton(
              onPressed: ()=> controller.pageController.previousPage(duration: const Duration(milliseconds: 300), 
curve: Curves.linear),
              icon: const Icon(Icons.arrow_back_ios, size: 15,),
            ),
            IconButton(
              onPressed: (){},
              icon: const Icon(Icons.arrow_forward_ios, size: 15,),
            ),
          ],
        );
      },

my page controller and previous page method

late PageController pageController = PageController();

  void previousPage({Duration? duration, Curve? curve}) {
    pageController.previousPage(
      duration: duration ?? const Duration(milliseconds: 300),
      curve: curve ?? Curves.linear,
    );
  }

Proper way to remove all events of a day?

What is the proper way to remove all events of a day?

I'm trying with below code

var controller = CalendarControllerProvider.of(context).controller;
var existingSlots = controller.getEventsOnDay(state.selectedDate);

existingSlots.forEach((event) {
    controller.remove(event);
});

E/flutter (21441): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Concurrent modification during iteration: Instance(length:29) of '_GrowableList'.
E/flutter (21441): #0 ListIterator.moveNext (dart:_internal/iterable.dart:336:7)
E/flutter (21441): #1 _MonthEvent.removeEvent (package:calendar_view/src/event_controller.dart:204:21)
E/flutter (21441): #2 _YearEvent.removeEvent (package:calendar_view/src/event_controller.dart:174:11)
E/flutter (21441): #3 EventController.remove (package:calendar_view/src/event_controller.dart:58:11)

Adding onCellTap callback breaks whole calendar

Why am I getting this when I introduce a callback. When I remove callback, adding method works fine.

โ•โ•โ•ก EXCEPTION CAUGHT BY WIDGETS LIBRARY โ•žโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
The following assertion was thrown building CalendarControllerProvider<dynamic>:
Assertion failed:
file:///......./hosted/pub.dartlang.org/calendar_view-0.0.4/lib/src/calendar_controller_provider.dart:25:9
..\โ€ฆ\src\calendar_controller_provider.dart:25
result != null
"No CalendarControllerProvider<Object?> found in context. To solve this issue either wrap material
app with 'CalendarControllerProvider<Object?>' or provide controller argument in respected calendar
view class."

Happens on web and mobile.

Flutter (Channel stable, 2.8.1)

Code:

class CalendarPage extends StatefulWidget {
  const CalendarPage({Key? key}) : super(key: key);

  @override
  State<CalendarPage> createState() => _CalendarPageState();
}

class _CalendarPageState extends State<CalendarPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CalendarView(),
    );
  }
}

class CalendarView extends StatefulWidget {
  const CalendarView({ Key? key }) : super(key: key);

  @override
  State<CalendarView> createState() => _CalendarViewState();
}

class _CalendarViewState extends State<CalendarView> {

  late EventController eventController;

  @override
  void initState() {
    eventController = EventController();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return CalendarControllerProvider(
      controller: eventController,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          MonthView(
            onCellTap: (a, c) {
            },
            // width: MediaQuery.of(context).size.width / 2,
          ),
          Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ElevatedButton(
                onPressed: () {
                  try {
                    final event = CalendarEventData(
                      date: DateTime(2022, 4, 25),
                      event: "Event 1", 
                      title: 'test',
                    );
                    eventController.add(event);                    
                  } catch (e) {
                    print("$e");
                  }
                }, 
                child: Text("Add"),
              ),
            ],
          )
        ],
      ),
    );
  }
}

is there a way to create dayView with 30 minutes slots

I want to create day view with with 30 minutes slots.
for now it giving 1 hour slots so i am unable to arrange two event in one slot
when i do this my event tile gets overflow
how can i solve this

this my whole code where

Rx eventController = EventController().obs;

print statement for startDate and endDate
start time----------------------2022-05-06 15:00:00.000
endTime--------------------2022-05-06 15:30:00.000
start time----------------------2022-05-06 12:00:00.000
endTime--------------------2022-05-06 12:30:00.000
start time----------------------2022-05-06 14:30:00.000
endTime--------------------2022-05-06 15:00:00.000
start time----------------------2022-05-06 14:00:00.000
endTime--------------------2022-05-06 14:30:00.000
CalendarEventData data = CalendarEventData(
title: "$name",
color: Colors.pinkAccent,
description: serviceName,
date: startTime,
startTime: startTime,
endDate: endTime,
endTime: endTime,
);
eventController.value.add(data);

`DayView(
controller: controller.eventController.value,
timeLineOffset: 0.5,
timeLineBuilder: (date) {
return Text(DateFormat("HH:mm").format(date));
},
liveTimeIndicatorSettings: HourIndicatorSettings(color: Colors.red),
verticalLineOffset: 40,
eventTileBuilder: (date, events, boundary, start, end) {
print(" length ${events.length}");
String str =
"${DateFormat("HH:mm").format(events[0].startTime)}-${DateFormat("HH:mm").format(events[0].endTime)} ${events[0].title.substring(0, events[0].title.length - 1)}";
return Container(
color: events[0].color,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Flexible(
child: Text("$str",
style: Get.textTheme.headline6.merge(
TextStyle(color: Get.theme.primaryColor),
)),
),
],
),
Row(
children: [
Flexible(child: Text("${events[0].description}")),
],
),
],
),
);
},
showVerticalLine: false,
// To display live time line in day view.
showLiveTimeLineInAllDays: true,
// To display live time line in all pages in day view.
heightPerMinute: 1.8,
eventArranger: SideEventArranger(),

                                onEventTap: (events, date) => print(events),
                              )`

mac@macs-Mac-mini-3 % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[โœ“] Flutter (Channel stable, 2.10.5, on macOS 11.5.2 20G95 darwin-x64, locale en-US)
[โœ“] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 12.5)
! Flutter recommends a minimum Xcode version of 13.
Download the latest version or update via the Mac App Store.
[โœ“] Chrome - develop for the web
[โœ“] Android Studio (version 2021.1)
[โœ“] Connected device (2 available)
[โœ“] HTTP Host Availability

! Doctor found issues in 1 category.
mac@macs-Mac-mini-3 zylu_business %

Cell error in week view

Events are stacked incorrectly, they are stacked on one side of the container without using the full width of the cell, which causes that you only see 2 colored lines when they could be expanded more.

WhatsApp Image 2022-08-29 at 2 06 46 PM

Modifying CalendarEventData

I currently had the problem that I wanted to modify an existing event entry (in particular change start and end time). However, I did not find an option to modify existing events in this library, so I went with the solution to delete the event from the EventController first, and then add it again, with modified values.

However, during this approach, I noticed that the event is not correctly deleted from the controller, but still remains stored in the _eventList variable, where it leads to the event supposed to be deleted being represented multiple times in the DayView after subsequent modifications (which then call remove on the controller).

wrong _currentIndex calculation for _minDate.timeOfDay > _currentDate.timeOfDay // DayView

I have encountered an issue with the _currentIndex calculation for the DayView.
To not have the events displayed one day off when the _minDate time of the day is greater than that of the _currentDate
the _currentDate and _minDate should be "normalized" to the same hour e.g.

DateTime _currentNormalizedToHour = DateTime(_currentDate.year, _currentDate.month, _currentDate.day, 0);
DateTime _minNormalizedToHour = DateTime(_minDate.year, _minDate.month, _minDate.day, 0);
_currentIndex = _currentNormalizedToHour.getDayDifference(_minNormalizedToHour);
// _currentIndex = _currentDate.getDayDifference(_minDate);

To also always get the expected _totalDays _maxDate should also be normalized.

It would therefore probably be most convenient to change the getDayDifference method

Unbounded height constraints when put as part of Sliver

Hi, I am trying to add the DayView in a Sliver, but whatever I try, I get one or other variation of "unbounded height constraints".
Code and exception below:

`Widget getCalendarView() {

return SliverList(
  delegate: SliverChildBuilderDelegate(
    (BuildContext context, int index) {
      return SingleChildScrollView(
        child: DayView(
          controller: EventController(),
        ),
      );
    },
    childCount: 1,
  ),
);

}`

I was looking for a way to declare that I want to shrink-wrap the DayView, but found none... any ideas?

Thanks and best regards
Kras

Exception:
The following assertion was thrown during performLayout():
RenderFlex children have non-zero flex but incoming height constraints are unbounded.

When a column is in a parent that does not provide a finite height constraint, for example if it is in a vertical scrollable, it will try to shrink-wrap its children along the vertical axis. Setting a flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining space in the vertical direction.
These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child cannot simultaneously expand to fit its parent.

Consider setting mainAxisSize to MainAxisSize.min and using FlexFit.loose fits for the flexible children (using Flexible rather than Expanded). This will allow the flexible children to size themselves to less than the infinite remaining space they would otherwise be forced to take, and then will cause the RenderFlex to shrink-wrap the children rather than expanding to fit the maximum constraints provided by the parent.

If this message did not help you determine the problem, consider using debugDumpRenderTree():
https://flutter.dev/debugging/#rendering-layer
http://api.flutter.dev/flutter/rendering/debugDumpRenderTree.html
The affected RenderFlex is: RenderFlex#408be relayoutBoundary=up17 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: (can use size)
constraints: BoxConstraints(w=411.4, 0.0<=h<=Infinity)
size: MISSING
direction: vertical
mainAxisAlignment: start
mainAxisSize: min
crossAxisAlignment: start
textDirection: ltr
verticalDirection: down
child 1: RenderDecoratedBox#419af NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
constraints: MISSING
size: MISSING
decoration: BoxDecoration
color: Color(0xffdcf0ff)
configuration: ImageConfiguration(bundle: PlatformAssetBundle#b0938(), devicePixelRatio: 2.6, locale: en_US, textDirection: TextDirection.ltr, platform: android)
child: RenderClipPath#eb64c NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData:
constraints: MISSING
size: MISSING
child: RenderFlex#84689 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData:
constraints: MISSING
size: MISSING
direction: horizontal
mainAxisAlignment: spaceBetween
mainAxisSize: max
crossAxisAlignment: center
needs compositing
parentData:
constraints: MISSING
size: MISSING
usefulness ratio: no metrics collected yet (never painted)
child: _RenderScrollSemantics#2aff5 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData:
constraints: MISSING
semantic boundary
size: MISSING
The creator information is set to: Column โ† DecoratedBox โ† SizedBox โ† MediaQuery โ† Padding โ† SafeArea โ† DayView โ† _SingleChildViewport โ† IgnorePointer-[GlobalKey#33e91] โ† Semantics โ† Listener โ† _GestureSemantics โ† โ‹ฏ

EventController remove event don't work

#28

I have a CalendarControllerProvider with an EventController. When i try to do :
_eventController.remove(event);

I've got this error :

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Concurrent modification during iteration: Instance(length:1224) of '_GrowableList'.
E/flutter (19491): #0      ListIterator.moveNext (dart:_internal/iterable.dart:336:7)
E/flutter (19491): #1      _MonthEvent.removeEvent (package:calendar_view/src/event_controller.dart:204:21)
E/flutter (19491): #2      _YearEvent.removeEvent (package:calendar_view/src/event_controller.dart:174:11)
E/flutter (19491): #3      EventController.remove (package:calendar_view/src/event_controller.dart:58:11)
E/flutter (19491): #4      _CalendarPageState.showCreateEditEventDialog (package:myapp/page/calendar_page/calendar_page.dart:468:26)

I think it's because in MonthEvent, in removeEvent (line 203). We try to remove an event when we read the list.

Is dark theme available for this widget?

Hi ,
Is there a way to enable dark mode for this calender view ?

I was able to change theme for timeLineBuilder and background in Day View. My issue is specifically with dayTitleBuilder. How can I customize dayTitleBuilder.?

Pinch-to-Zoom in Day and Month View

Hi, I just wantet to ask if there is any intent or idea how to implement a pinch-to-zoom for the DayView and the MonthView. Basically its just about changing the heighPerMinute parameter. I have looked into warping the whole thing in a GestureDetector but this didnt really work since the view is scrollable into two directions already.

Problem showing only 1 day in DayView

Before 1.0.0 (534f2b7) I could "hack" my way around this using:

DayView(  
minDay: DateTime.now(),  
maxDay: DateTime.now().add(const Duration(seconds: 1)),  
...
)

This is no longer possible. Is there a correct way of only displaying one day using the DayView?

OnTap

Hi, How to get OnTap event appointment details?

Tks. Luciano

I can't handle event added with EventController

The event I added with EventController seem not to work and the event won't be shown. Please tell me how to make it work.
I want you to tell me how to use this EventController with another MonthCalendar. I wish I use riverpod for it.
class WeekCalendar extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: WeekView( controller: EventController(), eventTileBuilder: (date, events, boundry, start, end) { // Return your widget to display as event tile. return Container(); }, showLiveTimeLineInAllDays: true, // To display live time line in all pages in week view. width: 400, // width of week view. heightPerMinute: 1, // height occupied by 1 minute time span. eventArranger: SideEventArranger(), // To define how simultaneous events will be arranged. onDateLongPress: (time) { try { final event = CalendarEventData( date: DateTime(2022, 6, 17), startTime: DateTime(2022, 6, 17, 15), endTime: DateTime(2022, 6, 17, 18), event: "Event 1", title: 'test', ); EventController().add(event); print(EventController().getEventsOnDay(DateTime(2022, 6, 17))); } catch (e) { print(e); } }, */ )); } }

Web - week view layout issue

Dear Simform Solutions,

Im Facing in issue in the week view when it shows in web view.
as shown in this image
im using it with fluent_ui i dont know if it help to check it

โ•โ•โ•ก EXCEPTION CAUGHT BY RENDERING LIBRARY โ•žโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• The following assertion was thrown during layout: The specific RenderFlex in question is: RenderFlex#23156 relayoutBoundary=up2 OVERFLOWING: creator: Row โ† SizedBox โ† Column โ† ConstrainedBox โ† Container โ† InternalWeekViewPage<Object?>-[<'602022-09-26 00:00:00.000'>] โ† ValueListenableBuilder<bool> โ† RepaintBoundary โ† IndexedSemantics โ† _SelectionKeepAlive โ† NotificationListener<KeepAliveNotification> โ† KeepAlive โ† โ‹ฏ parentData: <none> (can use size) constraints: BoxConstraints(w=895.0, 0.0<=h<=Infinity) size: Size(895.0, 45.0) direction: horizontal mainAxisAlignment: start mainAxisSize: max crossAxisAlignment: start textDirection: ltr verticalDirection: down โ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—คโ—ขโ—ค โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• Another exception was thrown: A RenderFlex overflowed by 265 pixels on the right. Another exception was thrown: A RenderFlex overflowed by 415 pixels on the right. Another exception was thrown: A RenderFlex overflowed by 265 pixels on the right.

Missing redraw events

Hello,

I'm using bloc and Tabbars

  final List<Widget> _views = [
    const DayView(),
    const WeekView(),
    const MonthView(),
  ];

  Widget get _calendar =>
      BlocBuilder<DataBloc, DataState>(builder: (context, state) {
        // if the data is fetched convert the appointments in events
        List<CalendarEventData<Appointment>> events = [];
        if (state is FetchedData) {
          events = (state.data as List<Appointment>)
              .map((appointment) => _appointmentToEvent(appointment))
              .toList(growable: false);
        }

        // Create the content
        return CalendarControllerProvider(
          controller: EventController()..addAll(events),
          child: TabBarView(children: _views),
        );
      });

I have three tabs: Day, Week and Month.
The WeekView is the middle tab and is the one selected by default.
As I'm using bloc the function _calendar will be called two time: on fetching data with events empty and on fetched data with events filled.

The WeekView calendar is drawn proper but without events. If I change tab and select once of the others I see the events on calendars DayView and also MonthView. Now when back to Week pressing on tab I see the events listed proper inside the calendar WeekView.

Thanks for your support.
Sam

Change default start hour in DayView

Is it possible to change the default start hour in DayView from 1am to something like 8am? I looked into the TimeLineMark, but am not what I should update it to.
Screen Shot 2022-04-01 at 12 28 59 PM

Month view scrolls too far to blank area

I'm adding MonthView() to my project and it scrolls to reveal the full month (which is fine) but it also scrolls past that and shows a blank area after that. I can't seem to get it to only scroll to show the month and nothing else (like in the example).

Screen.Recording.2022-10-05.at.2.28.45.PM.mov

My code structure is as follows:

DefaultTabController(
     child: Scaffold(
            ....
            body: TabBarView(....: [
                 ....
                 MonthView(),
            ])
    )
)

I've wrapped MonthView in a sizedbox or a container and it changes the size of the total widget but doesn't change the behavior. This is scrolling just the weeks, not the header (so not the entire MonthView widget) which makes me think this is a MonthView widget issue (or maybe I haven't formatted it correctly or something). Any insights would be appreciated!

More customization without creating our own builder

Hi!
Would it be possible to change some settings of the MonthView without using headerBuilder?
For example, change Icons colors, header's background color. (as you can see, all the changes would be focused on colors, because it's recurrent to customize them without having the need to change everything).

Thanks for this great package!

Add scroll offset for day and week view

#40

Hi,

I added a parameter to DayView and WeekView to manage the position of the scroll when first displayed.

For example, when we display the calendar, we prefer to display 8:00 a.m. at the top rather than 0:00 a.m.

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.