Highly customizable, feature-packed calendar widget for Flutter

Overview

Table Calendar

Pub Package Awesome Flutter

Highly customizable, feature-packed Flutter Calendar with gestures, animations and multiple formats.

Image Image
Table Calendar with custom styles Table Calendar with Builders

Features

  • Extensive, yet easy to use API
  • Custom Builders for truly flexible UI
  • Complete programmatic control with CalendarController
  • Dynamic events
  • Interface for holidays
  • Locale support
  • Vertical autosizing
  • Beautiful animations
  • Gesture handling
  • Multiple Calendar formats
  • Multiple days of the week formats
  • Specifying available date range
  • Nice, configurable UI out of the box

Usage

Make sure to check out example project. For additional info please refer to API docs.

Installation

Add to pubspec.yaml:

dependencies:
  table_calendar: ^2.3.3

Then import it to your project:

import 'package:table_calendar/table_calendar.dart';

And finally create the TableCalendar with a CalendarController:

@override
void initState() {
  super.initState();
  _calendarController = CalendarController();
}

@override
void dispose() {
  _calendarController.dispose();
  super.dispose();
}

@override
Widget build(BuildContext context) {
  return TableCalendar(
    calendarController: _calendarController,
  );
}

Locale

Table Calendar supports locales. To display the Calendar in desired language, use locale property. If you don't specify it, a default locale will be used.

Initialization

Before you can use a locale, you need to initialize the i18n formatting.

This is independent of Table Calendar package, so I encourage you to do your own research.

A simple way of doing it is as follows:

  • First of all, add intl package to your pubspec.yaml file
  • Then make modifications to your main():
import 'package:intl/date_symbol_data_local.dart';

void main() {
  initializeDateFormatting().then((_) => runApp(MyApp()));
}

After those two steps your app should be ready to use Table Calendar with different languages.

Specifying a language

To specify a language, simply pass it as a String code to locale property.

For example, this will make Table Calendar use Polish language:

TableCalendar(
  locale: 'pl_PL',
),
Image Image Image Image
'en_US' 'pl_PL' 'fr_FR' 'zh_CN'

Note, that if you want to change the language of FormatButton's text, you have to do this yourself. Use availableCalendarFormats property and pass the translated Strings there. Use i18n method of your choice.

You can also hide the button altogether by setting formatButtonVisible to false.

Holidays

Table Calendar provides a simple interface for displaying holidays. Here are a few steps to follow:

  • Fetch a map of holidays tied to dates. You can search for it manually, or perhaps use some online API
  • Convert it to a proper format - note that these are lists of holidays, since one date could have a couple of holidays:
{
  `DateTime A`: [`Holiday A1`, `Holiday A2`, ...],
  `DateTime B`: [`Holiday B1`, `Holiday B2`, ...],
  ...
}
  • Link it to Table Calendar. Use holidays property

And that's your basic setup! Now you can add some styling:

  • By using CalendarStyle properties: holidayStyle and outsideHolidayStyle
  • By using CalendarBuilders for complete UI control over calendar cell

You can also add custom holiday markers thanks to improved marker API. Check out example project for more details.

markersBuilder: (context, date, events, holidays) {
  final children = <Widget>[];

  if (events.isNotEmpty) {
    children.add(
      Positioned(
        right: 1,
        bottom: 1,
        child: _buildEventsMarker(date, events),
      ),
    );
  }

  if (holidays.isNotEmpty) {
    children.add(
      Positioned(
        right: -2,
        top: -2,
        child: _buildHolidaysMarker(),
      ),
    );
  }

  return children;
},
Comments
  • Feature Request : Events can be updated for each month

    Feature Request : Events can be updated for each month

    Thanks for such an awesome library. Can we have provision to update the events map, based on the month selected. Typically on load of each month, we send a request to server to get the events for that month. I tried updating the _events on each request's result, but the event markers are not reflecting as the controller is still referring to the previous events map.

    opened by pvsvamsi 33
  • Avoid blank space when swipping between two months

    Avoid blank space when swipping between two months

    This is a great project! But is it possible to reduce the time between 2 months when we swipe horizontally ? I would like to avoid the "blank" space between the two months.

    opened by adriende 29
  • [FEAT] - Disable navigation when selecting invisible days in the next or previous month

    [FEAT] - Disable navigation when selecting invisible days in the next or previous month

    Hi, great work with this project!

    Would it be possible to disable the navigation to the next/previous month when a date in the next/previous month is selected?

    As far as I can see the setSelectedDay method on the CalendarController always updates the visible days via _updateVisibleDays.

    https://github.com/aleksanderwozniak/table_calendar/blob/2cd1c7cabc3025bd227ce8cc2a32075d942a5df6/lib/src/calendar_controller.dart#L229-L233

    Perhaps we could supply the formats that this animation is enabled for? Defaulting to the current implementaton, which would be all except CalendarFormat.twoWeeks? Something similar to:

     void _updateVisibleDays(bool isProgrammatic) { 
       if (!navigateInvisibleDaysForFormats.any((x) => x == calendarFormat)  || isProgrammatic) { 
         _visibleDays.value = _getVisibleDays(); 
       } 
     } 
    
    opened by royston-c 21
  • Mode week event error.

    Mode week event error.

    When the calendar is in week mode, if I click on the 29th or 30th (if they are on the 1st and 2nd day each week), events from days 1 (Tuesday) through 5 (Saturday), next month, disappear.

    In month mode this does not happen as no two month events appear at the same time.

    opened by MarceloRab 16
  • Holidays not displaying

    Holidays not displaying

    Hi,

    I have changed the holiday years to 2020, but nothing appears when using the builder version.

    final Map<DateTime, List> _holidays = {
      DateTime(2020, 1, 1): ['New Year\'s Day'],
      DateTime(2020, 1, 6): ['Epiphany'],
      DateTime(2020, 2, 14): ['Valentine\'s Day'],
      DateTime(2020, 4, 21): ['Easter Sunday'],
      DateTime(2020, 4, 22): ['Easter Monday'],
    };
    
      Widget _buildHolidaysMarker() {
        return Icon(
          Icons.cake,
          size: 20.0,
          color: Colors.lightGreenAccent,
        );
      }
    

    image

    opened by KrunchMuffin 15
  • How to make today's list automatically show on the screen instead of tap the day to show it?

    How to make today's list automatically show on the screen instead of tap the day to show it?

    Hi, I have been working a lot trying to figure out how to use Table Calendar, right not I can add list or event to the calendar and on each day it will show dots, but everytime when I first open the calendar screen, it only show a calendar with dots below the date, but not showing the list, only if I tap on the day, it will show. Here is part of the code: onDaySelected: (date, events) { setState(() { _selectedList = _selectedDayEvents; }); }, And I can see today is the initial selectedDay, so today should be selected, but I can not automatically see today's list unless I tap on it. Is it designed this way? is there way to change?

    Any help is appreciated, Thank you!

    Lu

    opened by lutang123 14
  • Create event example

    Create event example

    Examples are great but since I moved to new version lots of things changed and I'm having different issues trying to refactor my code.

    Can you provide a quick example for events creation?

    opened by erperejildo 13
  • Locale 'ru_RU' doesn't work and throw an error. InitializeDateFormatting has beed used.

    Locale 'ru_RU' doesn't work and throw an error. InitializeDateFormatting has beed used.

    @aleksanderwozniak, Russian locale haven't work. I've done all by instruction. I found samples of code for Portuguese and implemented it and It works. But when I try to use Russian or Ukrainian or Belorussia it wont. I've even try Iraq and its work) but not with 'ru_RU' Screenshot 2021-03-14 at 17 35 38 Screenshot 2021-03-14 at 17 36 22 Screenshot 2021-03-14 at 17 36 46

    Originally posted by @KrillioSokolov in https://github.com/aleksanderwozniak/table_calendar/issues/417#issuecomment-798928612

    opened by KrillioSokolov 13
  • Widget state does not persist

    Widget state does not persist

    I need to switch screen layouts dynamically, conditionally showing the calendar widget. My problem is that the current month is reset to initialSelectedDay every time the widget shows. I'd think that it should respect the 'CalendarController.focusedDay` field since the controller instance is reused? Is it a bug?

    opened by duzenko 12
  • Bring CalendarController inside the plugin and expose it through callbacks

    Bring CalendarController inside the plugin and expose it through callbacks

    Breaking change that will require a major version bump. There is a big problem in the current architecture of the package. Two separate objects: TableCalendar and CalendarController. The state of TableCalendar completely depends on the state of CalendarController but users are responsible for instantiating each of these objects separately of one another themselves. This breaks encapsulation principle of object oriented design and makes the package difficult to use. If users want 3 calendars, they must instantiate 3 calendarcontroller, 3 tablecalendar and map the state of each calendar controller to the correct state of the specific tablecalendar that maps to that calendarcontroller. Presumably CalendarController was created for abstraction and/or to have TableCalendar be a smaller object. However the way it was implemented was causing significant problems with both hot reload and statefulness. This PR resolves those issues. Users no longer need to instantiate their own CalendarController. CalendarController is now inside of TableCalendar and instantiation occurs automatically. If the user needs to access the state of CalendarController for the builders, it is exposed as parameters.

    Fixes #243 Fixes #248

    Let me know if I missed anything.

    opened by shamilovtim 12
  • Wrong calendar format

    Wrong calendar format

    I'm using the table calendar, and i tried to set the calendar format to month, but what i got is: image

    I set to "Week" and the button display Month, and when i try set the calendar format from calendar controller (in the first load), i got the error: The setter 'value=' was called on null. Receiver: null Tried calling: value=Instance of 'CalendarFormat'

    I can't set the calendar format...

    opened by lucas-sesti 11
  • Try to adding some event to firebase

    Try to adding some event to firebase

    Describe the bug When I try to get the date for save any event in flutter firebase if I pick day 5 Jan 2023 when I save in firebase the day saved is 4 Jan 2023 I try to use toLocal, and toUtc, and issue always persist

    To reproduce Please include a short code sample that can be used to reproduce the problem.

    Code sample

    TableCalendar( focusedDay: _value, rangeStartDay: normalizeDate(_value.toUtc()), firstDay: DateTime(2022), lastDay: DateTime.now(), onDaySelected: (selectedDay, focusedDay) { if (selectedDay == selectedDay) { setState(() => _value = selectedDay); }

                            Navigator.pop(context);
                          },
                        );
    
    bug 
    opened by xTheMasters 0
  • TableBorder doesn't cut background color corners when rounded

    TableBorder doesn't cut background color corners when rounded

    Description Calendar Style doesn't cut corners when TableBorder is circular. Maybe some clipBehavior is needed.
    That looks my calendarStyle:

    calendarStyle: CalendarStyle(
              selectedDecoration: const BoxDecoration(color: AppColors.orange),
              defaultDecoration: const BoxDecoration(color: AppColors.inputFillAlpineGoat),
              weekendDecoration: const BoxDecoration(color: AppColors.inputFillAlpineGoat),
              outsideDaysVisible: false,
              isTodayHighlighted: false,
              cellMargin: EdgeInsets.zero,
              selectedTextStyle: h500TextStyle.copyWith(fontSize: 18.sp, color: AppColors.white),
              defaultTextStyle: h500TextStyle.copyWith(fontSize: 18.sp, color: AppColors.black),
              weekendTextStyle: h500TextStyle.copyWith(fontSize: 18.sp, color: AppColors.black),
              tableBorder: TableBorder.all(
                borderRadius: BorderRadius.circular(12.h),
                color: AppColors.neutralGray,
                width: 1.24.w,
              ),
            ),
    

    Screenshots Zrzut ekranu 2023-01-4 o 11 01 29

    bug 
    opened by radeckid 0
  • centring the Selected day

    centring the Selected day

    Is your feature request related to a problem? Please describe. Yes, I would like to keep the "selectedDay" to the center whenever a user changes it

    Describe the solution you'd like Whener a user chooses a different day, the calendar shall scroll to the center instead

    Screenshot 2022-11-27 at 3 09 31 PM enhancement 
    opened by PavieOlivier 0
Owner
Aleksander Woźniak
Flutter and Kotlin enthusiast, creator of ShapeQuest mobile game
Aleksander Woźniak
Calendar widget for flutter that is swipeable horizontally. This widget can help you build your own calendar widget highly customizable.

flutter_calendar_carousel Calendar widget for flutter that is swipeable horizontally. This widget can help you build your own calendar widget highly c

dooboolab 750 Jan 7, 2023
A Flutter package allows you to easily implement all calendar UI and calendar event functionality. 👌🔝🎉

calendar_view A Flutter package allows you to easily implement all calendar UI and calendar event functionality. For web demo visit Calendar View Exam

Simform Solutions 219 Dec 22, 2022
Flutter calendar app. register schedule and manage in calendar ui.

flutter calendar app. register schedule and manage in calendar ui. save schedule data in firestore. and create widget and read schedule from firestore in widget.

akiho 11 Oct 30, 2022
CalendarDatePicker2 - A lightweight and customizable calendar picker based on Flutter CalendarDatePicker

A lightweight and customizable calendar picker based on Flutter CalendarDatePicker, with support for single date picker, range picker and multi picker.

Neo Liu 27 Dec 22, 2022
Calendar widget for flutter

Calendar Shows a scrolling calendar list of events. This is still relatively basic, it always assumes that the getEvents returns the entire list of ca

null 223 Dec 19, 2022
Calendar widget library for Flutter apps.

Calendarro Calendar widget library for Flutter apps. Offers multiple ways to customize the widget. Getting Started Installation Add dependency to your

Adam Styrc 97 Nov 30, 2022
A calendar widget for Flutter.

flutter_calendar A calendar widget for Flutter Apps. Borrowed DateTime utility functions from the Tzolkin Calendar web element. Usage Add to your pubs

AppTree Software, Inc 336 Sep 6, 2022
A calendar widget to easily scroll through the years 🗓

Flutter Scrolling Calendar A customizable calendar widget to easily scroll through the years. Features Choose range of years and the initial year to s

Menno Renkens 113 Nov 19, 2022
A Flutter package for using Jalali (Shamsi, Solar, Persian or Jalaali) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi) dates.

A Flutter package for using Jalali (Shamsi, Solar, Persian or Jalaali) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi) dates.

Amirreza Madani 63 Dec 21, 2022
Flutter Date Picker Library that provides a calendar as a horizontal timeline.

DatePickerTimeline Flutter Date Picker Library that provides a calendar as a horizontal timeline. How To Use Import the following package in your dart

LiLi 0 Oct 25, 2021
Easy to use and beautiful calendar strip component for Flutter.

Flutter Calendar Strip Easy to use and beautiful calendar strip component for Flutter. Awesome celender widget If this project has helped you out, ple

Siddharth V 176 Dec 14, 2022
Flutter Date Picker Library that provides a calendar as a horizontal timeline

Flutter Date Picker Library that provides a calendar as a horizontal timeline.

Vivek Kaushik 214 Jan 7, 2023
Flutter Inline Calendar

inline_calendar An inline calendar flutter package inspired by outlook app. It also supports Jalali/Shamsi calendar. Uses theme and locale of context

omid habibi 3 Oct 21, 2022
Flutter calendar week UI package

Flutter calendar week Flutter calendar week UI package IOS | Android: import 'package:flutter_calendar_week/flutter_calendar_week.dart'; CalendarWeek(

null 67 Dec 12, 2022
A seasonal foods calendar app written in Dart using Flutter.

This project is not actively maintained anymore. However, everybody who wants to do so is more than welcome to work on this project! Thank you for you

Andreas Boltres 63 Nov 19, 2022
Collection of customisable calendar related widgets for Flutter.

calendar_views Collection of customisable calendar related widgets for Flutter. Day View Day View Documentation Set of widgets for displaying a day vi

Zen Lednik 99 Sep 8, 2022
Fluboard - Calendar wall-board-display built with Flutter and ❤️

Fluboard Calendar wall-board-display built with Flutter and ❤️ Goals Build calendar board (DAKBoard alternative) which easy to install and easy to cus

iTeqno 10 Dec 27, 2022
A Heatmap Calendar based on Github's contributions chart

Flutter Heat Map Calendar A Heat Map Calendar based on Github's contributions chart which can be used to visualize values over time Installing 1. Depe

Pedro H. F. Feitosa 49 Dec 6, 2022
Allows to use date pickers without dialog. Provides some customizable styles for date pickers.

flutter_date_pickers Allows to use date pickers without dialog. Provides some customizable styles for date pickers. A set of date pickers: DayPicker f

null 196 Dec 29, 2022