Amina Semhar

Amina Semhar

1595032500

Simple Calendar for Vue2

Tongcheng Yilong-Multi-mode calendar plug-in, support standard selection mode, hotel check-in and departure mode, aircraft round-trip mode, customizable theme colors

  • Calendar.vue can pass parameters to set the theme color, such as theme-color=“#ff6600 or #f60” (depending on less), such as sass can be modified in the source code style tag

  

+ In order to respond to everyone's various functional needs in a timely manner, we can spare no effort 
+ So I hope to click a star in the github link above, it can be considered as an encouragement! 
+ At the same time, if there are any new needs and suggestions, please continue to contact me, I will update in time

github link Link Name

Instructions

If installing in the vue-cli project: npm install mobile-calendar-simple -S (If you use uniapp tool HBuilderX to import, you can ignore this step)

< Template > 
< div > 
	< ! - the use of a: Start - DATE omitted i.e. default day , IsFixed whether full screen display orientation, the default to false  - > 
	< Calendar : Start-DATE = ' startDate ': IsFixed = " to true " @ the callback = "getDate" / >  
	< ! - usage 2: when mODE = 2 mode, respectively 3 (hotel \ to back) of the departure date - > 
	< Calendar : Start-dATE =" StartDate ": End-DATE = "endDate"  MODE = "2" @ the callback = "getDate" / > 
	< ! - Usage III: date range operation - > 
	< Calendar   : BETWEEN-Start = " startDate ": End-the BETWEEN = "endDate" @ callback = "getDate" / > 
	< ! - to set a theme color - > 
	< Calendar :themeColor="'#FF6600 ' "@ the callback = " getDate " / > 
	< ! - if necessary SOLT - > 
	< Calendar >
		...Slot injection is also supported here (no need to ignore)
		< template  v-slot : header > 
			< div > I am the head < / div > 
		< / template > 
		< template  v-slot : footer > 
			< div > I am the foot < / div > 
		< / template > 
	< / calendar > 
< / div > 
< / template > 
< script >
	import Calendar from 'mobile-calendar-simple'
	export default { 
		data ( ) { 
			return  { //Date is in yyyy-mm-dd or yyyy/mm/dd format 
				startDate : '' , 
				endDate : '' , 
				betweenStart : '' , 
				betweenEnd : '' , 
			} 
		} , 
		methods : { 
			//Get the date data of the callback 
			getDate ( date ) { 
				console . Log ( date ) 
			} 
		} , 
		components : {
			Calendar
		}
	}
</script>

The parameters are as follows

  • start-date The default day, when mode=2 and 3 are the departure date of (hotel\round trip) respectively
  • end-date When mode=2, 3 are the departure dates of (hotel\round trip) respectively
  • The date range between between-start and between-end can be operated
  • theme-color The theme color of the calendar, for example’#FF6600’ or shorthand’#f60’ (default #415FFB)
  • mode mode selection (default 1 standard mode), 2 hotel mode, 3 round trip mode
  • init-month initial month (default 6 months) minimum 1 month
  • title A section of text at the top of the calendar
  • isFixed Whether the calendar is positioned in full-screen display, the default is false

Callback

  • @callback: The data obtained after the date is selected (all you want)

Download Details:

Author: tanagang

GitHub: https://github.com/tanagang/mobile-calendar-simple

#vuejs #vue #javascript #vue-js

What is GEEK

Buddha Community

Simple Calendar for Vue2

Adding A Simple Calendar to Our Vue App with Vue2-simple-calendar

Adding a calendar widget by hand is very painful.

Therefore, many calendar component libraries are created.

vue2-simple-calendar is one library.

In this article, we’ll look at how to add a calendar with the vue2-simple-calendar library.

Getting Started

We add our library by installing it with NPM.

To do that, we run:

npm i vue2-simple-calendar

#javascript

Arun A

1623301384

Flutter Calendar Widget: Flexible Event Scheduler

  • Visualize vivid appointments in different views including day, week, month, schedule, and timeline.
  • Schedule recurring events and appointments in different time zones.
  • Style calendar elements easily.
  • Exclude nonworking days and nonworking hours to have a more focused view of your schedule.

The Flutter Event Calendar, or scheduler library, was natively written in Dart and has seven built-in, configurable view modes that provide basic functionalities for scheduling, managing, and representing appointments efficiently. This Flutter Calendar widget exposes a clean and convenient user interface for custom working days and working hours, and basic calendar operations such as date navigation and selection.
https://www.syncfusion.com/flutter-widgets/flutter-calendar

#flutter #scheduler #calendar #widget #event calendar

Mitchel  Carter

Mitchel Carter

1597392000

Flutter: Use Google Calendar API — Adding the events to Calendar

Introduction:

**Google Calendar API **can help to Get, Delete, Create events and many other things.

I am going to write steps to show how to create events in Google Calendar through Flutter app.

_If you want to get your Flutter project done. You can hire me at _Fiverr. Just drop a message

Beginning

You may want to skip steps from 1–11 if you’ve already Created the google console Project and Enabled Calendar API.

**1 — **Go to Google APIs dashboard https://console.developers.google.com/.

**2 — **Login through your Gmail account. (If you are already logged in then you may not need to log in again)

You will be now at dashboard like the following picture

Image for post

**3 — **Click the My Project (don’t worry if you see some other name).

Image for post

You will see the list of all Projects.

**4 — **Create a new Project

Image for post

**5 — **You can create a new Project here.

Note: You may see some warning like this **You have 2 projects remaining in your quota. Request an increase or delete projects. **This is the limit of the project that google clouds provide a user to create. Of course, you can increase it by requesting them.

You may see error **You’ve reached your project limit. You can create more projects after you request a project limit increase. **That means you have used your all limits. Now either requests them or delete at least one previous project to create a new project.

Image for post

**6 — **After Creating, you will be returned to dashboard. Confirm that the name of project is similar to that you have created. If not open the list of all projects by clicking here and Selecting your desired Project

#flutter #flutter-google-apis #google-calendar-api #google-calendar

Simple and Clean Flutter Calendar

flutter_neat_and_clean_calendar

Simple flutter calendar based on flutter_clean_calendar package. This package offers some extra functionality. It introduced a new NeatCleanCalendarEvent object, that gets used as the data component transfered the calendar widget as a parameter. So it is possible now to color the dots in the Calendartiles with a color corresponding to the event.

The event list below the calendar view is generated bei the package. Here the extra data of the NetCleanCalendarEvent objects again come into play.

The package is highly customizable.

Screenshot

 

Screenshot
Screenshot

Usage

Embed the 'Calendar' widget in a column. Below the calendar (as the second widget in the Column) place a 'ListView.builder' widget for rendereing the list of events.

Set dependency

dependencies:
  flutter_neat_and_clean_calendar: ^0.2.0+8

Install

flutter pub get

Import it

import 'package:flutter_neat_and_clean_calendar/flutter_neat_and_clean_calendar.dart';

Use it

Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Calendar(
          startOnMonday: true,
          weekDays: ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'],
          events: _events,
          isExpandable: true,
          eventDoneColor: Colors.green,
          selectedColor: Colors.pink,
          todayColor: Colors.blue,
          // dayBuilder: (BuildContext context, DateTime day) {
          //   return new Text("!");
          // },
          eventListBuilder: (BuildContext context,
              List<NeatCleanCalendarEvent> _selectesdEvents) {
            return new Text("!");
          },
          eventColor: Colors.grey,
          locale: 'de_DE',
          todayButtonText: 'Heute',
          expandableDateFormat: 'EEEE, dd. MMMM yyyy',
          dayOfWeekStyle: TextStyle(
              color: Colors.black, fontWeight: FontWeight.w800, fontSize: 11),
        ),
      ),
    );
  }

For more details see the example.

Properties

/// [onDateSelected] is of type [ValueChanged<DateTime>] and it containes the callback function
///     extecuted when tapping a date
/// [onMonthChanged] is of type [ValueChanged<DateTime>] and it containes the callback function
///     extecuted when changing to another month
/// [onExpandStateChanged] is of type [ValueChanged<bool>] and it contains a callback function
///     executed when the view changes to expanded or to condensed
/// [onRangeSelected] contains a callback function of type [ValueChanged], that gets called on changes
///     of the range (switch to next or previous week or month)
/// [onEventSelected] is of type [ValueChanged<NeatCleanCalendarEvent>] and it contains a callback function
///     executed when an event of the event list is selected
/// [isExpandable] is a [bool]. With this parameter you can control, if the view can expand from week view
///     to month view. Default is [false].
/// [dayBuilder] can contain a [Widget]. If this property is not null (!= null), this widget will get used to
///     render the calenar tiles (so you can customize the view)
/// [eventListBuilder] can optionally contain a [Widget] that gets used to render the event list
/// [hideArrows] is a bool. When set to [true] the arrows to navigate to the next or previous week/month in the
///     top bar well get suppressed. Default is [false].
/// [hideTodayIcon] is a bool. When set to [true] the dispaly of the Today-Icon (button to navigate to today) in the
///     top bar well get suppressed. Default is [false].
/// [hideBottomBar] at the moment has no function. Default is [false].
/// [events] are of type [Map<DateTime, List<NeatCleanCalendarEvent>>]. This data structure containes the events to display
/// [selctedColor] this is the color, applied to the circle on the selcted day
/// [todayColor] this is the color of the date of today
/// [todayButtonText] is a [String]. With this property you can set the caption of the today icon (button to navigate to today).
///     If left empty, the calendar will use the string "Today".
/// [eventColor] lets you optionally specify the color of the event (dot). If the [CleanCaendarEvents] property color is not set, the
///     calendar will use this parameter.
/// [eventDoneColor] with this property you can define the color of "done" events, that is events in the past.
/// [initialDate] is of type [DateTime]. It can contain an optional start date. This is the day, that gets initially selected
///     by the calendar. The default is to not set this parameter. Then the calendar uses [DateTime.now()]
/// [isExpanded] is a bool. If is us set to [true], the calendar gets rendered in month view.
/// [weekDays] contains a [List<String>] defining the names of the week days, so that it is possible to name them according
///     to your current locale.
/// [locale] is a [String]. This setting gets used to format dates according to the current locale.
/// [startOnMonday] is a [bool]. This parameter allows the calendar to determine the first day of the week.
/// [dayOfWeekStyle] is a [TextStyle] for styling the text of the weekday names in the top bar.
/// [bottomBarTextStyle] is a [TextStyle], that sets the style of the text in the bottom bar.
/// [bottomBarArrowColor] can set the [Color] of the arrow to expand/compress the calendar in the bottom bar.
/// [bottomBarColor] sets the [Color] of the bottom bar
/// [expandableDateFormat] defines the formatting of the date in the bottom bar
final ValueChanged<DateTime> onDateSelected;
final ValueChanged<DateTime> onMonthChanged;
final ValueChanged<bool> onExpandStateChanged;
final ValueChanged onRangeSelected;
final ValueChanged<NeatCleanCalendarEvent> onEventSelected;
final bool isExpandable;
final DayBuilder dayBuilder;
final EventListBuilder eventListBuilder;
final bool hideArrows;
final bool hideTodayIcon;
final Map<DateTime, List<NeatCleanCalendarEvent>> events;
final Color selectedColor;
final Color todayColor;
final String todayButtonText;
final Color eventColor;
final Color eventDoneColor;
final DateTime initialDate;
final bool isExpanded;
final List<String> weekDays;
final String locale;
final bool startOnMonday;
final bool hideBottomBar;
final TextStyle dayOfWeekStyle;
final TextStyle bottomBarTextStyle;
final Color bottomBarArrowColor;
final Color bottomBarColor;
final String expandableDateFormat;

Sample event data

The syntax of the event map changed due to the introduction of the 'NeatCleanCalendarEvent' class.

final Map<DateTime, List<NeatCleanCalendarEvent>> _events = {
    DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day): [
      NeatCleanCalendarEvent('Event A',
          startTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day, 10, 0),
          endTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day, 12, 0),
          description: 'A special event',
          color: Colors.blue[700]),
    ],
    DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day + 2):
        [
      NeatCleanCalendarEvent('Event B',
          startTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 10, 0),
          endTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 12, 0),
          color: Colors.orange),
      NeatCleanCalendarEvent('Event C',
          startTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 14, 30),
          endTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 17, 0),
          color: Colors.pink),
    ],
  };

Examples

Basic wirget with customized colors

Some colors were cutomized in this example:

Calendar(
  eventDoneColor: Colors.green,
  selectedColor: Colors.pink,
  todayColor: Colors.blue,
  eventColor: Colors.grey,
)
Screenshot

Expandable calendar view

Calendar(
  isExpandable: true;
)
Screenshot
Screenshot

Custom day builder

Calendar(
  // A builder function that renders each calendar tile how you'd like.
  dayBuilder: (BuildContext context, DateTime day) {
      return new Text("!");
  },
)
Screenshot

Custom event list builder

Calendar(
  // A builder function that renders the event list
  eventListBuilder: (BuildContext context,
      List<NeatCleanCalendarEvent> _selectesdEvents) {
    return new Text("!");
  },
)
Screenshot

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add flutter_neat_and_clean_calendar

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  flutter_neat_and_clean_calendar: ^0.2.3+11

Alternatively, your editor might support or flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:flutter_neat_and_clean_calendar/flutter_neat_and_clean_calendar.dart'; 

example/lib/main.dart

import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_neat_and_clean_calendar/flutter_neat_and_clean_calendar.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Clean Calendar Demo',
      home: CalendarScreen(),
    );
  }
}

class CalendarScreen extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _CalendarScreenState();
  }
}

class _CalendarScreenState extends State<CalendarScreen> {
  List<NeatCleanCalendarEvent> _todaysEvents = [
    NeatCleanCalendarEvent('Event A',
        startTime: DateTime(DateTime.now().year, DateTime.now().month,
            DateTime.now().day, 10, 0),
        endTime: DateTime(DateTime.now().year, DateTime.now().month,
            DateTime.now().day, 12, 0),
        description: 'A special event',
        color: Colors.blue[700]),
  ];
  final Map<DateTime, List<NeatCleanCalendarEvent>> _events = {
    DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day + 2):
        [
      NeatCleanCalendarEvent('Event B',
          startTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 10, 0),
          endTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 12, 0),
          color: Colors.orange),
      NeatCleanCalendarEvent('Event C',
          startTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 14, 30),
          endTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 17, 0),
          color: Colors.pink),
    ],
    DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day + 3):
        [
      NeatCleanCalendarEvent('Event B',
          startTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 10, 0),
          endTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 12, 0),
          color: Colors.orange),
      NeatCleanCalendarEvent('Event C',
          startTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 14, 30),
          endTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 17, 0),
          color: Colors.pink),
      NeatCleanCalendarEvent('Event D',
          startTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 14, 30),
          endTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 17, 0),
          color: Colors.amber),
      NeatCleanCalendarEvent('Event E',
          startTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 14, 30),
          endTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 17, 0),
          color: Colors.deepOrange),
      NeatCleanCalendarEvent('Event F',
          startTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 14, 30),
          endTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 17, 0),
          color: Colors.green),
      NeatCleanCalendarEvent('Event G',
          startTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 14, 30),
          endTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 17, 0),
          color: Colors.indigo),
      NeatCleanCalendarEvent('Event H',
          startTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 14, 30),
          endTime: DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day + 2, 17, 0),
          color: Colors.brown),
    ],
  };

  @override
  void initState() {
    super.initState();
    _events.putIfAbsent(
        DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day),
        () => _todaysEvents);
    // Force selection of today on first load, so that the list of today's events gets shown.
    _handleNewDate(DateTime(
        DateTime.now().year, DateTime.now().month, DateTime.now().day));
  }

  @override
  Widget build(BuildContext context) {
    print(_events.length);
    return Scaffold(
      body: SafeArea(
        child: Calendar(
          startOnMonday: true,
          weekDays: ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'],
          events: _events,
          isExpandable: true,
          eventDoneColor: Colors.green,
          selectedColor: Colors.pink,
          todayColor: Colors.blue,
          eventColor: Colors.grey,
          locale: 'de_DE',
          todayButtonText: 'Heute',
          isExpanded: true,
          expandableDateFormat: 'EEEE, dd. MMMM yyyy',
          dayOfWeekStyle: TextStyle(
              color: Colors.black, fontWeight: FontWeight.w800, fontSize: 11),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          // Add your onPressed code here!
          Random random = Random();
          // Pick a random number in the range [0.0, 1.0)
          double randomDouble = random.nextDouble();
          _todaysEvents.add(NeatCleanCalendarEvent('New Event',
              startTime: DateTime(
                  DateTime.now().year,
                  DateTime.now().month,
                  DateTime.now().day,
                  DateTime.now().hour,
                  DateTime.now().minute),
              endTime: DateTime(
                  DateTime.now().year,
                  DateTime.now().month,
                  DateTime.now().day,
                  DateTime.now().hour,
                  DateTime.now().minute + 15),
              description: 'New event',
              color:
                  Color((randomDouble * 0xFFFFFF).toInt()).withOpacity(1.0)));
          setState(() {
            _events[DateTime(DateTime.now().year, DateTime.now().month,
                DateTime.now().day)] = _todaysEvents;
          });
        },
        child: const Icon(Icons.add),
        backgroundColor: Colors.green,
      ),
    );
  }

  void _handleNewDate(date) {
    print('Date selected: $date');
  }
} 

Download Details:

Author: rwbr

Source Code: https://github.com/rwbr/flutter_neat_and_clean_calendar

#calendar #flutter 

A Simple Paginated Framework for Implementing Calendar

A simple paginated framework for implementing calendar based interfaces.

gif showing of package customizability gif showing dat range picker example gif showing paged data example 

:hammer: How it works

paged_vertical_calendar is a very minimalistic framework that automatically loads months based on scoll behavior. It provides many useful callbacks to implement your own calendar interactions and builders to customize the calendar as much as you want. Check the example for several implementations like date range selection and paginated data visualisation.

PagedVerticalCalendar has no required parameters and can be dropped in anywhere providing it has a fixed height.

Scaffold(
  home: PagedVerticalCalendar(),
);

:loudspeaker: Callbacks

Several callback are provided to facilitate easy implementation of any calendar interactions

PagedVerticalCalendar(
  invisibleMonthsThreshold: 1,
  onMonthLoaded: (year, month) {
    // on month widget load 
  },
  onDayPressed: (value) {
    // on day widget pressed   
  },
  onPaginationCompleted: () {
    // on pagination completion
  },
);

onMonthLoaded is a callback that fires for every month added to the list. When this function fires can be altered by setting the invisibleMonthsThreshold pararamter.

invisibleMonthsThreshold decides how many months outside of the widgets view should be loaded. In other words, how many months should be preloaded before the user reaches that scroll position. It defaults to 1.

onDayPressed is a simple onPressed callback but also provides the DateTime of the day that has been pressed.

finally when an endDate is provided to the PagedVerticalCalendar, the onPaginationCompleted callback can be used. This is a VoidCallBack that indicates when all the months have been loaded.

:art: Customization

PagedVerticalCalendar provides default calendar styling, but these can be fully customized. To do so, several builders are provided:

PagedVerticalCalendar(
  monthBuilder: (context, month, year) {
    // provide a month header widget
  },
  dayBuilder: (context, date) {
    // provide a day widget
  },
);

monthBuilder provides the year and month as integers. this builder has to return a widget that will form the header of ever month. the intl package works well here for date formatting.

dayBuilder provides the day as a DateTime. this builder wil be called for every day. You usually want to provide at least a text widget with the current day number.

:wave: Get Involved

If this package is useful to you please :thumbsup: on pub.dev and :star: on github. If you have any Issues, recommendations or pull requests I'd love to see them!

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add paged_vertical_calendar

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  paged_vertical_calendar: ^1.0.3

Alternatively, your editor might support or flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:paged_vertical_calendar/paged_vertical_calendar.dart'; 

example/lib/main.dart

import 'dart:math';

import 'package:flutter/material.dart';
import 'package:paged_vertical_calendar/paged_vertical_calendar.dart';
import 'package:intl/intl.dart';

void main() => runApp(Home());

/// a simple example showing several ways this package can be used
/// to implement calendar related interfaces.
class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) => MaterialApp(
        home: DefaultTabController(
          length: 3,
          child: Scaffold(
            appBar: AppBar(
              title: const Text('Paged Vertical Calendar'),
              bottom: TabBar(
                indicatorSize: TabBarIndicatorSize.label,
                tabs: [
                  Tab(icon: Icon(Icons.calendar_today), text: 'Custom'),
                  Tab(icon: Icon(Icons.date_range), text: 'DatePicker'),
                  Tab(icon: Icon(Icons.dns), text: 'Pagination'),
                ],
              ),
            ),
            body: TabBarView(
              children: [
                Custom(),
                DatePicker(),
                Pagination(),
              ],
            ),
          ),
        ),
      );
}

/// simple demonstration of the calendar customizability
class Custom extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return PagedVerticalCalendar(
      /// customize the month header look by adding a week indicator
      monthBuilder: (context, month, year) {
        return Column(
          children: [
            /// create a customized header displaying the month and year
            Container(
              padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 20),
              margin: const EdgeInsets.all(20),
              decoration: BoxDecoration(
                color: Theme.of(context).primaryColor,
                borderRadius: BorderRadius.all(Radius.circular(50)),
              ),
              child: Text(
                DateFormat('MMMM yyyy').format(DateTime(year, month)),
                style: Theme.of(context).textTheme.bodyText1!.copyWith(
                      color: Colors.white,
                    ),
              ),
            ),

            /// add a row showing the weekdays
            Padding(
              padding: const EdgeInsets.symmetric(horizontal: 20.0),
              child: Row(
                mainAxisSize: MainAxisSize.max,
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  weekText('Mo'),
                  weekText('Tu'),
                  weekText('We'),
                  weekText('Th'),
                  weekText('Fr'),
                  weekText('Sa'),
                  weekText('Su'),
                ],
              ),
            ),
          ],
        );
      },

      /// added a line between every week
      dayBuilder: (context, date) {
        return Column(
          children: [
            Text(DateFormat('d').format(date)),
            const Divider(),
          ],
        );
      },
    );
  }

  Widget weekText(String text) {
    return Padding(
      padding: const EdgeInsets.all(4.0),
      child: Text(
        text,
        style: TextStyle(color: Colors.grey, fontSize: 10),
      ),
    );
  }
}

/// simple example showing how to make a basic date range picker with
/// UI indication
class DatePicker extends StatefulWidget {
  @override
  _DatePickerState createState() => _DatePickerState();
}

class _DatePickerState extends State<DatePicker> {
  /// store the selected start and end dates
  DateTime? start;
  DateTime? end;

  /// method to check wether a day is in the selected range
  /// used for highlighting those day
  bool isInRange(DateTime date) {
    // if start is null, no date has been selected yet
    if (start == null) return false;
    // if only end is null only the start should be highlighted
    if (end == null) return date == start;
    // if both start and end aren't null check if date false in the range
    return ((date == start || date.isAfter(start!)) &&
        (date == end || date.isBefore(end!)));
  }

  @override
  Widget build(BuildContext context) {
    return PagedVerticalCalendar(
      addAutomaticKeepAlives: true,
      dayBuilder: (context, date) {
        // update the days color based on if it's selected or not
        final color = isInRange(date) ? Colors.green : Colors.transparent;

        return Container(
          color: color,
          child: Center(
            child: Text(DateFormat('d').format(date)),
          ),
        );
      },
      onDayPressed: (date) {
        setState(() {
          // if start is null, assign this date to start
          if (start == null)
            start = date;
          // if only end is null assign it to the end
          else if (end == null)
            end = date;
          // if both start and end arent null, show results and reset
          else {
            print('selected range from $start to $end');
            start = null;
            end = null;
          }
        });
      },
    );
  }
}

/// simple example on how to display paginated data in the calendar and interact
/// with it.
class Pagination extends StatefulWidget {
  @override
  _PaginationState createState() => _PaginationState();
}

class _PaginationState extends State<Pagination> {
  /// list holding all the items we are displaying
  List<DateTime> items = [];

  /// called every time a new month is loaded
  void fetchNewEvents(int year, int month) async {
    Random random = Random();
    // this is where you would load your custom data, sync or async
    // this data does require a date so you can later filter on that
    // date
    final newItems = List<DateTime>.generate(random.nextInt(40), (i) {
      return DateTime(year, month, random.nextInt(27) + 1);
    });

    // add to all our fetched items and update UI
    setState(() => items.addAll(newItems));
  }

  @override
  Widget build(BuildContext context) {
    return PagedVerticalCalendar(
      // to prevent the data from being reset every time a user loads or
      // unloads this widget
      addAutomaticKeepAlives: true,
      // when the new month callback fires, we want to fetch the items
      // for this month
      onMonthLoaded: fetchNewEvents,
      dayBuilder: (context, date) {
        // from all our items get those that are supposed to be displayed
        // on this day
        final eventsThisDay = items.where((e) => e == date);
        return Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(DateFormat('d').format(date)),
            // for every event this day, add a small indicator dot
            Wrap(
              children: eventsThisDay.map((event) {
                return Padding(
                  padding: const EdgeInsets.all(1),
                  child: CircleAvatar(
                    radius: 5,
                    backgroundColor: Colors.red,
                  ),
                );
              }).toList(),
            )
          ],
        );
      },
      onDayPressed: (day) {
        // when a day is pressed we can check which events are linked to this
        // day and do something with them. e.g. open a new page
        final eventsThisDay = items.where((e) => e == day);
        print('items this day: $eventsThisDay');
      },
    );
  }
} 

Download Details:

Author: casvanluijtelaar

Source Code: https://github.com/casvanluijtelaar/paged_vertical_calendar

#calendar #flutter