parseDuration function
Implementation
Duration parseDuration(String s) {
var hours = 0;
var minutes = 0;
var seconds = 0;
final parts = s.split(':');
if (parts.length > 2) {
hours = int.tryParse(parts[parts.length - 3]) ?? 0;
}
if (parts.length > 1) {
minutes = int.tryParse(parts[parts.length - 2]) ?? 0;
}
seconds = int.tryParse(parts[parts.length - 1]) ?? 0;
return Duration(
hours: hours,
minutes: minutes,
seconds: seconds,
);
}