FLineCalendar constructor

FLineCalendar({
  1. required FCalendarController<DateTime?> controller,
  2. FLineCalendarStyle? style,
  3. AlignmentDirectional initialDateAlignment = AlignmentDirectional.center,
  4. double? cacheExtent,
  5. ValueWidgetBuilder<FLineCalendarItemData> builder = _builder,
  6. DateTime? start,
  7. DateTime? end,
  8. DateTime? initial,
  9. DateTime? today,
  10. Key? key,
})

Creates a FLineCalendar.

start represents the start date, inclusive. It is truncated to the nearest date. Defaults to the DateTime.utc(1900).

end represents the end date, exclusive. It is truncated to the nearest date.

initial represents the initial date that will appear on the left-most edge on LTR locales. It is truncated to the nearest date.

today represents the current date. It is truncated to the nearest date. Defaults to the DateTime.now.

Contract

Throws AssertionError if:

  • end <= start.
  • initial < start or end <= initial.
  • today < start or end <= today.

Implementation

FLineCalendar({
  required this.controller,
  this.style,
  this.initialDateAlignment = AlignmentDirectional.center,
  this.cacheExtent,
  this.builder = _builder,
  DateTime? start,
  DateTime? end,
  DateTime? initial,
  DateTime? today,
  super.key,
})  : _start = (start ?? DateTime.utc(1900)).toLocalDate(),
      _end = end?.toLocalDate(),
      _initial = initial?.toLocalDate(),
      _today = (today ?? DateTime.now()).toLocalDate(),
      assert(
        start == null || end == null || start.toLocalDate() < end.toLocalDate(),
        'end date must be greater than start date',
      ),
      assert(
        initial == null ||
            start == null ||
            (initial.toLocalDate() >= start.toLocalDate() && initial.toLocalDate() < end!.toLocalDate()),
        'initial date must be greater than or equal to start date',
      ),
      assert(
        today == null ||
            start == null ||
            (today.toLocalDate() >= start.toLocalDate() && today.toLocalDate() < end!.toLocalDate()),
        'initial date must be greater than or equal to start date',
      );