Validates if a string represents a valid hexadecimal number.
bool isValidHex(String input) { final regex = RegExp(r'^[0-9A-Fa-f]+$'); return regex.hasMatch(input.trim()); }