isValidTimeFormat static method

bool isValidTimeFormat(
  1. String timeString
)

Validates if a given time string is in the correct format (HH:MM).

@param timeString The time string to validate @return true if the format is valid, false otherwise

Implementation

static bool isValidTimeFormat(String timeString) {
  // Regular expression to validate HH:MM format
  final regex = RegExp(r'^([01]?[0-9]|2[0-3]):([0-5][0-9])$');
  return regex.hasMatch(timeString);
}