parseOffsetToDuration static method

Duration parseOffsetToDuration(
  1. String offset
)

Implementation

static Duration parseOffsetToDuration(String offset) {
  // Check if it's a negative offset
  bool isNegative = offset.startsWith('-');
  int hours = int.parse(offset.substring(1, 3));
  int minutes = int.parse(offset.substring(3, 5));

  Duration duration = Duration(hours: hours, minutes: minutes);
  return isNegative ? -duration : duration;
}