Skip to content

Commit bc45e46

Browse files
committed
Use clock package in workout_logs.dart
This is needed in order to be able to mock the current time in the tests
1 parent b0e6b3d commit bc45e46

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed
File renamed without changes.

lib/widgets/routines/workout_logs.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
import 'package:clock/clock.dart';
1920
import 'package:flutter/material.dart';
2021
import 'package:table_calendar/table_calendar.dart';
2122
import 'package:wger/helpers/consts.dart';
@@ -98,7 +99,7 @@ class WorkoutLogCalendar extends StatefulWidget {
9899
}
99100

100101
class _WorkoutLogCalendarState extends State<WorkoutLogCalendar> {
101-
DateTime _focusedDay = DateTime.now();
102+
DateTime _focusedDay = clock.now();
102103
DateTime? _selectedDay;
103104
late final ValueNotifier<List<WorkoutLogEvent>> _selectedEvents;
104105
late Map<String, List<WorkoutLogEvent>> _events;
@@ -152,8 +153,8 @@ class _WorkoutLogCalendarState extends State<WorkoutLogCalendar> {
152153
children: [
153154
TableCalendar(
154155
locale: Localizations.localeOf(context).languageCode,
155-
firstDay: DateTime.now().subtract(const Duration(days: 1000)),
156-
lastDay: DateTime.now(),
156+
firstDay: clock.now().subtract(const Duration(days: 1000)),
157+
lastDay: clock.now(),
157158
focusedDay: _focusedDay,
158159
selectedDayPredicate: (day) => isSameDay(_selectedDay, day),
159160
calendarFormat: CalendarFormat.month,

0 commit comments

Comments
 (0)