diff --git a/lib/date_picker_widget.dart b/lib/date_picker_widget.dart index 14ca445..bbb365f 100644 --- a/lib/date_picker_widget.dart +++ b/lib/date_picker_widget.dart @@ -59,6 +59,11 @@ class DatePicker extends StatefulWidget { /// Locale for the calendar default: en_us final String locale; + //===================== PROPOSED =======================// + /// If providing Active or Deactivated Dates, + // Allow hiding the widgets so there are no spaces in between active dates + final bool hideDeactivatedDates; + DatePicker( this.startDate, { @@ -78,6 +83,8 @@ class DatePicker extends StatefulWidget { this.daysCount = 500, this.onDateChange, this.locale = "en_US", +//===================== PROPOSED =======================// + this.hideDeactivatedDates = false, }) : assert( activeDates == null || inactiveDates == null, "Can't " @@ -173,40 +180,44 @@ class _DatePickerState extends State { _currentDate != null ? _compareDate(date, _currentDate!) : false; // Return the Date Widget - return DateWidget( - date: date, - monthTextStyle: isDeactivated - ? deactivatedMonthStyle - : isSelected - ? selectedMonthStyle - : widget.monthTextStyle, - dateTextStyle: isDeactivated - ? deactivatedDateStyle - : isSelected - ? selectedDateStyle - : widget.dateTextStyle, - dayTextStyle: isDeactivated - ? deactivatedDayStyle - : isSelected - ? selectedDayStyle - : widget.dayTextStyle, - width: widget.width, - locale: widget.locale, - selectionColor: - isSelected ? widget.selectionColor : Colors.transparent, - onDateSelected: (selectedDate) { - // Don't notify listener if date is deactivated - if (isDeactivated) return; - - // A date is selected - if (widget.onDateChange != null) { - widget.onDateChange!(selectedDate); - } - setState(() { - _currentDate = selectedDate; - }); - }, - ); + return +//===================== PROPOSED: Wrap in visibility widget to hide it if deactivated =========================// + Visibility( + child: DateWidget( + date: date, + monthTextStyle: isDeactivated + ? deactivatedMonthStyle + : isSelected + ? selectedMonthStyle + : widget.monthTextStyle, + dateTextStyle: isDeactivated + ? deactivatedDateStyle + : isSelected + ? selectedDateStyle + : widget.dateTextStyle, + dayTextStyle: isDeactivated + ? deactivatedDayStyle + : isSelected + ? selectedDayStyle + : widget.dayTextStyle, + width: widget.width, + locale: widget.locale, + selectionColor: + isSelected ? widget.selectionColor : Colors.transparent, + onDateSelected: (selectedDate) { + // Don't notify listener if date is deactivated + if (isDeactivated) return; + + // A date is selected + if (widget.onDateChange != null) { + widget.onDateChange!(selectedDate); + } + setState(() { + _currentDate = selectedDate; + }); + }, + ), + visible: widget.hideDeactivatedDates == true && isDeactivated == true ? false : true ); }, ), );