diff --git a/CHANGELOG.md b/CHANGELOG.md index 52364c6..a0581de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [0.3.6+19] - 2022-06-03 +* Issue #37 closed + ## [0.3.5+18] - 2022-05-04 * Option to change color of selected day when same date as today diff --git a/lib/flutter_neat_and_clean_calendar.dart b/lib/flutter_neat_and_clean_calendar.dart index 6513b5a..2e93c4f 100644 --- a/lib/flutter_neat_and_clean_calendar.dart +++ b/lib/flutter_neat_and_clean_calendar.dart @@ -185,6 +185,19 @@ class _CalendarState extends State { super.initState(); isExpanded = widget.isExpanded; + _selectedDate = widget.initialDate ?? DateTime.now(); + initializeDateFormatting(widget.locale, null).then((_) => setState(() { + var monthFormat = + DateFormat('MMMM yyyy', widget.locale).format(_selectedDate); + displayMonth = + '${monthFormat[0].toUpperCase()}${monthFormat.substring(1)}'; + })); + } + + /// The method [_updateEventsMap] has the purpose to update the eventsMap, when the calendar widget + /// renders its view. When this method executes, it fills the eventsMap with the contents of the + /// given eventsList. This can be used to update the events shown by the calendar. + void _updateEventsMap() { eventsMap = widget.events ?? {}; // If the user provided a list of events, then convert it to a map, but only if there // was no map of events provided. To provide the events in form of a map is the way, @@ -260,21 +273,16 @@ class _CalendarState extends State { } }); } - - _selectedDate = widget.initialDate ?? DateTime.now(); selectedMonthsDays = _daysInMonth(_selectedDate); selectedWeekDays = Utils.daysInRange( _firstDayOfWeek(_selectedDate), _lastDayOfWeek(_selectedDate)) .toList(); - initializeDateFormatting(widget.locale, null).then((_) => setState(() { - var monthFormat = - DateFormat('MMMM yyyy', widget.locale).format(_selectedDate); - displayMonth = - '${monthFormat[0].toUpperCase()}${monthFormat.substring(1)}'; - })); + _selectedEvents = eventsMap?[DateTime( _selectedDate.year, _selectedDate.month, _selectedDate.day)] ?? []; + + print('eventsMap has ${eventsMap?.length} entries'); } Widget get nameAndIconRow { @@ -714,6 +722,8 @@ class _CalendarState extends State { @override Widget build(BuildContext context) { + _updateEventsMap(); + // If _selectedEvents is not null, then we sort the events by isAllDay propeerty, so that // all day events are displayed at the top of the list. // Slightly inexxficient, to do this sort each time, the widget builds. diff --git a/pubspec.lock b/pubspec.lock index 70ca11f..619802a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -42,14 +42,14 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" flutter: dependency: "direct main" description: flutter @@ -80,7 +80,7 @@ packages: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "0.1.4" meta: dependency: transitive description: @@ -94,7 +94,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" sky_engine: dependency: transitive description: flutter @@ -106,7 +106,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -141,20 +141,13 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.8" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "0.4.9" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" sdks: - dart: ">=2.14.0 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index ab590d7..52988a1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: >- Simple and clean flutter calendar with ability to slide up/down to show weekly/monthly calendar. Fork of https://pub.dev/packages/flutter_clean_calendar -version: 0.3.5+18 +version: 0.3.6+19 homepage: https://github.com/rwbr/flutter_neat_and_clean_calendar environment: