Current Week Date Picker Flutter

Viewed 525

I'm trying to build this date picker which would only show the current week & always start from Monday to Friday

Current Week Date from Monday to Friday

I've tried using package calendar_timeline 1.0.4 and flutter_calendar_week 2.0.0 but they won't allow me to achieve my desired behavior.

I'd like to show Monday to Friday of current DateTime.now() week as shown on picture above

Using calendar_timeline 1.0.4 I achieved the following code bellow

  • but I'd like to find a way to make firstDate always the Monday of current DateTime.now() week, I'm also open to other solutions
  CalendarTimeline(
              showYears: true,
              initialDate: _selectedDate, 
              firstDate: MONDAY,// I'd like the first Date to always be a Monday of current week
              lastDate: FRIDAY,  // I'd like the last Date to always be a Friday of current week
              onDateSelected: (date) {
                setState(() {
                  _selectedDate = date;
                });
              },
              leftMargin: 20,
              monthColor: Colors.white70,
              dayColor: Colors.teal[200],
              dayNameColor: Color(0xFF333A47),
              activeDayColor: Colors.white,
              activeBackgroundDayColor: Colors.redAccent[100],
              dotsColor: Color(0xFF333A47),
              selectableDayPredicate: (date) => date.day != 23,
              locale: 'en',
            ),

1 Answers

you dont need to implement a third party package , flutter provide better date picker. you can use flutter date picker.

  showDatePicker(context: context, initialDate: initialDate, firstDate: firstDate, lastDate: lastDate);
Related