whenMaybe<T> method

T whenMaybe<T>({
  1. T bool()?,
  2. T int()?,
  3. T num()?,
  4. T str()?,
  5. T option(
    1. SerdeTypeOption
    )?,
  6. T duration()?,
  7. T list(
    1. SerdeTypeList
    )?,
  8. T set(
    1. SerdeTypeSet
    )?,
  9. T map(
    1. SerdeTypeMap
    )?,
  10. T function()?,
  11. T nested(
    1. SerdeTypeNested
    )?,
  12. T union(
    1. SerdeTypeUnion
    )?,
  13. T unionType(
    1. SerdeTypeUnionType
    )?,
  14. T enumV(
    1. SerdeTypeEnum<Object?>
    )?,
  15. T dynamic()?,
  16. T late(
    1. SerdeTypeLate
    )?,
  17. required T orElse(),
})

Implementation

T whenMaybe<T>({
  T Function()? bool,
  T Function()? int,
  T Function()? num,
  T Function()? str,
  T Function(SerdeTypeOption)? option,
  T Function()? duration,
  T Function(SerdeTypeList)? list,
  T Function(SerdeTypeSet)? set,
  T Function(SerdeTypeMap)? map,
  T Function()? function,
  T Function(SerdeTypeNested)? nested,
  T Function(SerdeTypeUnion)? union,
  T Function(SerdeTypeUnionType)? unionType,
  T Function(SerdeTypeEnum<Object?>)? enumV,
  T Function()? dynamic,
  T Function(SerdeTypeLate)? late,
  required T Function() orElse,
}) {
  T orElseParam(Object _) => orElse();

  return when(
    bool: bool ?? orElse,
    int: int ?? orElse,
    num: num ?? orElse,
    str: str ?? orElse,
    option: option ?? orElseParam,
    duration: duration ?? orElse,
    list: list ?? orElseParam,
    set: set ?? orElseParam,
    map: map ?? orElseParam,
    function: function ?? orElse,
    nested: nested ?? orElseParam,
    union: union ?? orElseParam,
    unionType: unionType ?? orElseParam,
    enumV: enumV ?? orElseParam,
    dynamic: dynamic ?? orElse,
    late: late ?? orElseParam,
  );
}