isTimeBeforeOther method

bool isTimeBeforeOther(
  1. String otherTime
)

Implementation

bool isTimeBeforeOther(String otherTime) {
  try {
    final thisParts = split(':');
    final otherParts = otherTime.split(':');

    if (thisParts.length != 2 || otherParts.length != 2) {
      return false; // Formato inválido
    }

    final thisHours = int.parse(thisParts[0]);
    final thisMinutes = int.parse(thisParts[1]);
    final otherHours = int.parse(otherParts[0]);
    final otherMinutes = int.parse(otherParts[1]);

    if (thisHours < otherHours) {
      return true;
    } else if (thisHours == otherHours) {
      return thisMinutes < otherMinutes;
    } else {
      return false;
    }
  } catch (e) {
    return false;
  }
}