Line data Source code
1 : import 'package:alh_calendar/models/calendar_week.dart'; 2 : import 'package:flutter/cupertino.dart'; 3 : 4 : /// Represents a month of the calendar 5 : @immutable 6 : class CalendarMonth { 7 : /// DateTime of the month. 8 : final DateTime month; 9 : 10 : /// Every month has a list of CalendarWeeks. Unlike real months the 11 : /// calendarMonth consists of 5 or 6 weeks, which are displayed in 12 : /// on the TableView. 13 : final List<CalendarWeek> weeks; 14 : 15 4 : const CalendarMonth({ 16 : required this.month, 17 : required this.weeks, 18 20 : }) : assert(weeks.length == 5 || weeks.length == 6); 19 : 20 2 : @override 21 : bool operator ==(Object other) { 22 2 : return (other is CalendarMonth) && 23 6 : other.month == this.month && 24 2 : this._isWeekEqual( 25 2 : calendarWeek: this.weeks, 26 2 : other: other.weeks, 27 : ); 28 : } 29 : 30 0 : @override 31 0 : int get hashCode => month.hashCode; 32 : 33 2 : bool _isWeekEqual({ 34 : required List<CalendarWeek> calendarWeek, 35 : required List<CalendarWeek> other, 36 : }) { 37 6 : for (int week = 0; week < calendarWeek.length; week++) { 38 6 : if (calendarWeek[week] != other[week]) { 39 : return false; 40 : } 41 : } 42 : return true; 43 : } 44 : }