Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight selected date when click on the month view cell #233

Open
jawadabbasi923 opened this issue Jun 8, 2023 · 0 comments
Open

Highlight selected date when click on the month view cell #233

jawadabbasi923 opened this issue Jun 8, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@jawadabbasi923
Copy link

I want to update selected date color to a custom color but could't found any property like selected date.
Is it possible to highlight the date when I click on any cell ?

Code :

MonthView(
controller: calendarController.eventController,
cellAspectRatio: 1.2,
width: 345.w,
initialMonth: DateTime.now(),
minMonth: DateTime.now(),
maxMonth: DateTime.now().add(const Duration(days: 365)),
showBorder: false,
headerStyle: const HeaderStyle(
decoration: BoxDecoration(
color: AppColor.transparent,
),
),
cellBuilder: (date, event, isToday, isInMonth) {
return Container(
decoration: BoxDecoration(
color: isToday ? AppColor.primaryColor : AppColor.transparent,
borderRadius: BorderRadius.circular(10.r),
),
child: Center(
child: Text(
date.day.toString(),
style: TextStyle(
color: isToday ? Colors.white : Colors.black,
fontWeight: FontWeight.bold,
),
),
),
);
},
weekDayBuilder: (day) => SizedBox(
height: 20.h,
child: Center(
child: Text(
calendarController.days[day],
style: const TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
),
),
headerStringBuilder: (date, {secondaryDate}) {
return '${calendarController.months[date.month - 1]} ${date.year}';
},
headerBuilder: (date) => SizedBox(
height: 50.h,
child: Container(
decoration: const BoxDecoration(
color: AppColor.transparent,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
onPressed: () {},
icon: const Icon(
Icons.arrow_back_ios,
color: Colors.black,
),
),
Text(
'${calendarController.months[date.month - 1]} ${date.year}',
style: const TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
IconButton(
onPressed: () {},
icon: const Icon(
Icons.arrow_forward_ios,
color: Colors.black,
),
),
],
),
),
),
onCellTap: (events, date) {},
)

@jaiminrana05 jaiminrana05 added the enhancement New feature or request label Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants