build method

  1. @override
ActivityModel build()

Implementation

@override
ActivityModel build() {
  // If the selectedDay from the calendar is in the future,
  // Use that date as the start date. Otherwise, use the current date.
  final selectedDay = ref.read(calendarProvider).selectedDay;
  final now = DateTime.now();

  final startDate = selectedDay.isBefore(now)
      ? now
      : selectedDay.add(const Duration(hours: 12));
  final endDate = startDate.add(const Duration(hours: 1));

  return ActivityModel(
    id: ref.read(firestoreServiceProvider).getEmptyDocumentID(),
    posterId: ref.watch(currentUserProvider)!.uid,
    date: (startDate, endDate),
  );
}