isDateAfterToday method

bool isDateAfterToday(
  1. DateTime dateToCheck
)

Checks if a given date is after today.

This method takes a DateTime object as an argument and returns true if the date is after today, and false otherwise.

Example:

DateTime dateToCheck = ... // the date you want to check
if (isDateAfterToday(dateToCheck)) {
  // dateToCheck is after today
}

Implementation

bool isDateAfterToday(DateTime dateToCheck) {
  // Get the current date and time
  final DateTime now = DateTime.now();

  // Create a new DateTime object representing today at midnight
  final DateTime endOfToday = DateTime(now.year, now.month, now.day)
      .add(const Duration(days: 1))
      .subtract(const Duration(microseconds: 1)); // Just before midnight

  // Check if the given date is after today and return the result
  return dateToCheck.isAfter(endOfToday);
}