View

https://pub.dev/packages/table_calendar

import 'package:table_calendar/table_calendar.dart';

...

CalendarController _calendarController = CalendarController();
Map<DateTime, List<EventsModel>> _events;
DateTime _selectedDay;

...

  Widget _buildCalendarCustom() {
    return TableCalendar(
      locale: 'ko-KR',
      calendarController: _calendarController,
      events: _events,
      availableGestures: AvailableGestures.all,
      onDaySelected: _onDaySelected,
      builders: calendarBuilder(),
      headerVisible: false,
    );
  }

  void _onDaySelected(DateTime day, List e) {
    setState(() {
      _selectedDay = day;
      e.length == 0 ? _selectedEvents = [] : _selectedEvents = e;
    });
  }

Calendar Builders


Here, I have specified the values for the each builders to visualize their sections on the calenderπŸ€—

각 builder의 κ°’λ“€ λˆˆμ— λ„κ²Œλ” μ μš©ν•΄λ³΄μ•˜μŠ΅λ‹ˆλ‹€πŸ€— (λ””μžμΈ ν…ŒλŸ¬λ²”)

calendarBuilder -> call

CalendarBuilders calendarBuilder() {
    return CalendarBuilders(
      selectedDayBuilder: (context, date, _) {
        return DaisyWidget().buildCalendarDay(
            day: date.day.toString(), backColor: DaisyColors.main4Color);
      },
      todayDayBuilder: (context, date, _) {
        return DaisyWidget().buildCalendarDay(
            day: date.day.toString(), backColor: DaisyColors.backgroundColor);
      },
      dayBuilder: (context, date, _) {
        return DaisyWidget().buildCalendarDay(
            day: date.day.toString(), backColor: Colors.white);
      },
      weekendDayBuilder: (context, date, _) {
        return DaisyWidget().buildCalendarDay(
            day: date.day.toString(),
            backColor: Colors.white,
            color: Colors.red);
      },
      outsideDayBuilder: (context, date, _) {
        return DaisyWidget().buildCalendarDay(
            day: date.day.toString(),
            backColor: Colors.blue,
            color: Colors.red);
      },
      outsideHolidayDayBuilder: (context, date, _) {
        return DaisyWidget().buildCalendarDay(
            day: date.day.toString(),
            backColor: Colors.deepOrange,
            color: Colors.red);
      },
      holidayDayBuilder: (context, date, _) {
        return DaisyWidget().buildCalendarDay(
            day: date.day.toString(),
            backColor: Colors.purple,
            color: Colors.red);
      },
      outsideWeekendDayBuilder: (context, date, _) {
        return DaisyWidget().buildCalendarDay(
            day: date.day.toString(),
            backColor: Colors.pinkAccent,
            color: Colors.black);
      },
      dowWeekdayBuilder: (context, date) {
        return DaisyWidget().buildCalendarDay(
            day: date.toString(), backColor: Colors.yellow, color: Colors.red);
      },
      dowWeekendBuilder: (context, date) {
        return DaisyWidget().buildCalendarDay(
            day: date.toString(), backColor: Colors.green, color: Colors.red);
      },
      unavailableDayBuilder: (context, date, _) {
        return DaisyWidget().buildCalendarDay(
            day: date.day.toString(),
            backColor: Colors.red,
            color: DaisyColors.serveColor);
      },
      markersBuilder: (context, date, events, holidays) {
        final children = <Widget>[];
        if (events.isNotEmpty) {
          children.add(
            Positioned(
              bottom: 1,
              child: _buildEventsMarkerNum(date),
            ),
          );
        }
        return children;
      },
    );
  }

MarkerBuilder -> call

Widget _buildEventsMarkerNum(List events) {
      return DaisyWidget().buildCalendarDayMarker(
          text: '${events.length}',
          backColor: privateLength == 0
              ? DaisyColors.main0Color
              : DaisyColors.serveColor);
    }


buildCalendarDay() , Marker()

Container buildCalendarDay({
     String day,
     Color backColor,
    Color color,
  }) {
    return Container(
      color: backColor,
      width: 53,
      height: 53,
      child: Center(
        child: Text(day,
            style: TextStyle(fontSize: 12, color: color ?? Colors.black)),
      ),
    );
  }

  AnimatedContainer buildCalendarDayMarker({
     String text,
     Color backColor,
  }) {
    return AnimatedContainer(
      duration: Duration(milliseconds: 300),
      decoration: BoxDecoration(
        shape: BoxShape.rectangle,
        color: backColor,
      ),
      width: 52,
      height: 13,
      child: Center(
        child: Text(
          text,
          style: TextStyle().copyWith(
            color: Colors.white,
            fontSize: 10.0,
          ),
        ),
      ),
    );
  }


Result

result calendar builder code

CalendarBuilders calendarBuilder() {
    return CalendarBuilders(
      selectedDayBuilder: (context, date, _) {
        return DaisyWidget().buildCalendarDay(
            day: date.day.toString(), backColor: DaisyColors.main4Color);
      },
      todayDayBuilder: (context, date, _) {
        return DaisyWidget().buildCalendarDay(
            day: date.day.toString(), backColor: DaisyColors.backgroundColor);
      },
      dayBuilder: (context, date, _) {
        return DaisyWidget().buildCalendarDay(
            day: date.day.toString(), backColor: Colors.white);
      },
      weekendDayBuilder: (context, date, _) {
        return DaisyWidget().buildCalendarDay(
            day: date.day.toString(),
            backColor: Colors.white,
            color: Colors.red);
      },
      outsideDayBuilder: (context, date, _) {
        return DaisyWidget().buildCalendarDay(
            day: date.day.toString(),
            backColor: Colors.white,
            color: Colors.black26);
      },
      outsideWeekendDayBuilder: (context, date, _) {
        return DaisyWidget().buildCalendarDay(
            day: date.day.toString(),
            backColor: Colors.white,
            color: Colors.red[100]);
      },
      dowWeekdayBuilder: (context, date) {
        return DaisyWidget().buildCalendarDay(
            day: date.toString(),
            backColor: Colors.white,
            color: Colors.black87);
      },
      dowWeekendBuilder: (context, date) {
        return DaisyWidget().buildCalendarDay(
            day: date.toString(),
            backColor: Colors.white,
            color: Colors.red[400]);
      },
      markersBuilder: (context, date, events, holidays) {
        final children = <Widget>[];
        if (events.isNotEmpty) {
          children.add(
            Positioned(
              bottom: 1,
              child: _buildEventsMarkerNum(date, events),
            ),
          );
        }
        return children;
      },
    );
  }
profile
𝙸 πšŠπš– 𝚊 πšŒπšžπš›πš’πš˜πšžπšœ πšπšŽπšŸπšŽπš•πš˜πš™πšŽπš› πš πš‘πš˜ πšŽπš—πš“πš˜πš’πšœ πšπšŽπšπš’πš—πš’πš—πš 𝚊 πš™πš›πš˜πš‹πš•πšŽπš–. πŸ‡°πŸ‡·πŸ‘©πŸ»β€πŸ’»

6개의 λŒ“κΈ€

comment-user-thumbnail
2020λ…„ 10μ›” 19일

κ°μ‚¬ν•©λ‹ˆλ‹€. 덕뢄에 달λ ₯ μ»€μŠ€ν…€μ— μ„±κ³΅ν–ˆμ–΄μš” !

λ‹΅κΈ€ 달기
comment-user-thumbnail
2021λ…„ 2μ›” 10일

ν˜Ήμ‹œ onDaySelected 에 events.. 이거 κ°’ λ“€μ–΄μ˜€μ‹œλ‚˜μš”?? γ… γ… 

1개의 λ‹΅κΈ€
comment-user-thumbnail
2021λ…„ 7μ›” 4일

Hello, can you tell me what is Daisy Widget exactly

λ‹΅κΈ€ 달기
comment-user-thumbnail
2021λ…„ 10μ›” 27일

table_calendar package μ—…λ°μ΄νŠΈλ˜λ©΄μ„œ makersBuilder μͺ½ Input/return λ‚΄μš©μ΄ λ³€κ²½λœκ²ƒ κ°™μŠ΅λ‹ˆλ‹€. (ver ^3.0.3)

parameter name : makersBuilder: -> makerBuilder:
input function : (context, date, events, holidays) {} -> (context, date, events) {}
return : [] -> Widget (κΈ°μ‘΄μ—λŠ” List[T] ν˜•νƒœλ‘œ λ°›μ€κ±Έλ‘œ λ³΄μ΄λ‚˜, μ§€κΈˆμ€ Widgetν•˜λ‚˜λ§Œ λ„£μœΌλ©΄ μžλ™μœΌλ‘œ iter λŒλ©΄μ„œ λ„£μ–΄μ£ΌλŠ” 것 κ°™μŠ΅λ‹ˆλ‹€)

  markerBuilder: (context, date, events) {
        return events.isNotEmpty ?  _buildEventsMarkerNum(events) : Container();
  },

μœ„ μ˜ˆμ œμ—μ„œ μ•ˆλ˜μ‹œλŠ”λΆ„λ“€μ€ μš”λ ‡κ²Œ λ³€κ²½ν•΄μ„œ λ„£μ–΄μ£Όμ‹œλ©΄ μ•„λ§ˆ 될것 κ°™μŠ΅λ‹ˆλ‹€. νŒ¨ν‚€μ§€ λ‚΄λΆ€λ‘œ λ“€μ–΄κ°€λ©΄, νŒŒμ•…ν•  수 μžˆλŠ” λ‚΄μš©μ΄μ§€λ§Œ ν˜Ήμ‹œλ‚˜ ν—€λ©”μ‹€ 뢄듀을 μœ„ν•΄ λŒ“κΈ€ λ‚¨κΉλ‹ˆλ‹€..

λ‹΅κΈ€ 달기
comment-user-thumbnail
2022λ…„ 5μ›” 1일

μ•ˆλ…•ν•˜μ„Έμš” ν˜Ήμ‹œ μ œκ°€ μ΄ˆλ³΄μ—¬μ„œκ·ΈλŸ°λ° μ €λ ‡κ²Œ μ„€λͺ…ν•΄μ„œ 잘λͺ¨λ₯΄κ² μ–΄μ„œ κ·ΈλŸ°λ°μš”γ… γ… γ…  ν˜Ήμ‹œ μ–΄λŠ 뢀뢄에 μ–΄λŠ 코딩을 λ„£μ–΄μ•Όλ˜κ³  κ·Έλž˜μ•Όλ κΉŒμš”γ… γ… ? κ·Έ 달λ ₯ κΈ°λ³Έ uiλŠ” 이미 μžˆμŠ΅λ‹ˆλ‹€. / 그리고 μ œκ°€ μ›ν•˜λŠ” λ‚  ν΄λ¦­ν•˜λ©΄ 색 ν‘œμ‹œκ°€ λ˜λŠ”κ²ƒκ³Ό κ·Έ ν‘œμ‹œν•œκ±Έ μ €μž₯ν•˜κ³ μ‹Άμ€λ° κ·Έ κ΅¬ν˜„μ€ μ—†μ„κΉŒμš”γ… γ…  (μ œκ°€ μ•ŒκΈ°λ‘œλŠ” dbμ—°κ²°ν•΄μ•Όν•˜λŠ”κ±Έλ‘œ μ•Œκ³ μžˆμŠ΅λ‹ˆλ‹€)

λ‹΅κΈ€ 달기