LocalTime.parse constructor

LocalTime.parse(
  1. String text
)

Parses HH:mm[:ss[.ffffff]] without a timezone.

Implementation

factory LocalTime.parse(String text) {
  final match = _syntax.firstMatch(text);
  if (match == null || match.end != text.length) {
    throw const FormatException(
      'Expected a time without a timezone, with at most six fractional digits.',
    );
  }
  return LocalTime(
    int.parse(match[1]!),
    int.parse(match[2]!),
    int.parse(match[3] ?? '0'),
    int.parse((match[4] ?? '').padRight(6, '0')),
  );
}