d2calendar 0.0.3 copy "d2calendar: ^0.0.3" to clipboard
d2calendar: ^0.0.3 copied to clipboard

outdated

Flutter d2 Calendar Package to build your own monthly Calendar or yearly Calendar.

How to Use the CalendarWidget #

To use the CalendarWidget in your Flutter application, follow the steps below:

[Image] [Image] [Image]
  1. Add the necessary dependencies to your pubspec.yaml file:

    dependencies:
      flutter:
        sdk: flutter
    d2calendar: ^0.0.3
    
  2. Import package

    
    import 'package:d2calendar/Calendar/CalendarWrapper.dart';
    
  3. Initialize class

    CalendarWrapper wrapper = CalendarWrapper(2023);
    
  4. Add Calendar to your UI

    wrapper.Calendar(
             red: red,
             yellow: yellow,
             month: 'October',
             callback: (selectedList, obj) {
               // Handle the selected list and object here
    		print(selectedList); // Boolean list of Days Selected
    		print(obj); //Return Selected Date's
             },
             singleDay: false,
             theme: 'light',
             notSelectDates: not_select_dates,
           ),
    

    Wrap this inside a Container or pass it in ListView children (field).


  1. Initialize list to show red and Yellow dots.

    	List<int> red = [1, 2]; // This will Add a red Dot below 1st and 2nd of Selected Month
    	List<int> yellow = [2, 3, 31, 32, 33, 34, 35, 36]; // similar(#red)
    	List<int> not_select_dates = [22, 23];
    

  1. About class Wrapper class

CalendarWrapper Class #

The CalendarWrapper class is responsible for generating a calendar for a specific year and providing access to individual months.

Constructor: #

CalendarWrapper(int year)

  • Constructs a new CalendarWrapper instance with the specified year.

Methods: #

void init_(year)

  • Initializes the calendar by generating the months for the specified year.

void printData()

  • Prints the data for each month in the calendar.

List<String> getJanuary()

  • Returns the list of days for the month of January.

List<String> getFebruary()

  • Returns the list of days for the month of February.

List<String> getMarch()

  • Returns the list of days for the month of March.

List<String> getApril()

  • Returns the list of days for the month of April.

List<String> getMay()

  • Returns the list of days for the month of May.

List<String> getJune()

  • Returns the list of days for the month of June.

List<String> getJuly()

  • Returns the list of days for the month of July.

List<String> getAugust()

  • Returns the list of days for the month of August.

List<String> getSeptember()

  • Returns the list of days for the month of September.

List<String> getOctober() - Returns the list of days for the month of October.

List<String> getNovember()

  • Returns the list of days for the month of November.

List<String> getDecember()

  • Returns the list of days for the month of December.

void setMonth(int month)

  • Sets the current month to the specified month value.

void setYear(int year)

  • Sets the current year to the specified year value.

    
    Widget Calendar({
    required red,
    required yellow,
    required month,
    required callback,
    required single_day,
    required theme,
    required not_select_dates,
    })
    
    
  • Generates a calendar widget for the specified month using the provided parameters. The red parameter is a list of integers representing days marked as red. The yellow parameter is a list of integers representing days marked as yellow. The callback is a function that is called when a day is selected. The single_day parameter indicates if only one day can be selected. The theme parameter defines the theme of the calendar. The not_select_dates parameter is a list of integers representing days that cannot be selected.

JSON Structure from CalendarUtil class (Not Wrapper Class) #

JSON Month

{
  "name": "January",
  "year": 2023,
  "days": [
    {"1": "Sunday"},
    {"2": "Monday"},
    {"3": "Tuesday"},
    ...
    {"31": "Tuesday"}
  ],
  "data": [
    "2023-1-01",
    "2023-1-02",
    ...
    "2023-1-31"
  ]
}

  • name: (String): The name of the month.
  • year: (int): The year of the month.
  • days: (List<Map<int, String>>): The list of days in the month, where each day is represented as a map containing the day number (key) and the corresponding weekday name (value).
  • data: (List

Json Year

{
  "year": 2023,
  "months": [
    {
      "name": "January",
      "year": 2023,
      "days": [
        {"1": "Sunday"},
        {"2": "Monday"},
        ...
        {"31": "Tuesday"}
      ],
      "data": [
        "2023-1-01",
        ...
        "2023-1-30",
        "2023-1-31"
      ]
    },
    // Include JSON representations of other months here
  ]
}
  • year: (int): The year.
  • months (List
12
likes
0
points
38
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter d2 Calendar Package to build your own monthly Calendar or yearly Calendar.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, intl, logger

More

Packages that depend on d2calendar

Packages that implement d2calendar