CalendarWeekViewModel constructor

CalendarWeekViewModel(
  1. BuildContext context, {
  2. AbstractApiInterface? apiInterface,
  3. DateTime? initialDate,
})

Creates a CalendarWeekViewModel with the given repository and template provider.

It listens to changes in the CalendarTemplateProvider to refetch events when the selected template changes.

Implementation

CalendarWeekViewModel(BuildContext context,
    {AbstractApiInterface? apiInterface, DateTime? initialDate})
    : _calendarRepository =
          context.read<CalendarMonthRepository>(), // Read from Provider
      _templateProvider = context.read<CalendarTemplateProvider?>(),
      _displayDate = initialDate ?? DateTime.now() {
  // Initialize _displayDate here
  _templateProvider?.addListener(_onDependenciesChanged);
}