getDuration method

Duration getDuration(
  1. String key, {
  2. Duration defVal = const Duration(seconds: 0),
})

Gets the value for a given key as a Duration. Returns defVal if the key does not exist.

Implementation

Duration getDuration(String key, {Duration defVal = const Duration(seconds: 0)}) {
  var res = getInt(key, defVal: defVal.inSeconds);
  if (res < 0) {
    res = 0;
  }
  return Duration(seconds: res);
}