serialToDateTime static method

  1. @useResult
DateTime? serialToDateTime(
  1. String? dateWithT
)

Parses a serial date string (ISO 8601 format) to DateTime.

Args: dateWithT: A date string in ISO 8601 format (e.g., "20231225T120000").

Returns: A DateTime object, or null if the string is null, empty, or invalid.

Implementation

@useResult
static DateTime? serialToDateTime(String? dateWithT) {
  if (dateWithT == null || dateWithT.isEmpty) {
    return null;
  }

  return DateTime.tryParse(dateWithT);
}