isNowInRange method

  1. @useResult
bool isNowInRange({
  1. DateTime? now,
  2. bool isInclusive = true,
})

Returns true if now is within this range.

By default, this check is isInclusive, meaning if now equals the start or end of the range, it is considered within the range.

NOTE: You can't really make date optional, even if looking for now, because of microsecond precision. So just cache DateTime.now() and pass it in for consistent results.

Implementation

@useResult
bool isNowInRange({DateTime? now, bool isInclusive = true}) {
  final DateTime resolvedNow = now ?? DateTime.now();

  return inRange(resolvedNow, isInclusive: isInclusive);
}