Time.fromString constructor

Time.fromString(
  1. String time, {
  2. String divider = ':',
  3. bool local = true,
})

Implementation

factory Time.fromString(String time, {String divider = ':', bool local = true}) {
  var decomposed = time.split(divider);
  if (time.length < 2) return Time(hour: 0, minute: 0);
  return Time(
    hour: int.parse(decomposed[0]),
    minute: int.parse(decomposed[1]),
    seconds: time.length == 3 ? int.parse(decomposed[2]) : 0,
    local: local,
  );
}