maybeValue<T extends Object> method

T? maybeValue<T extends Object>({
  1. T desktop()?,
  2. T tablet()?,
  3. T phone()?,
  4. T tinyHardware()?,
})

Proxies the call to value but allows all arguments to be null

When not a single argument is non-nullable, instead of throwing, returns a null instead.

Implementation

T? maybeValue<T extends Object>({
  T Function()? desktop,
  T Function()? tablet,
  T Function()? phone,
  T Function()? tinyHardware,
}) {
  if (desktop == null && tablet == null && phone == null && tinyHardware == null) {
    return null;
  }

  return value(desktop: desktop, tablet: tablet, phone: phone, tinyHardware: tinyHardware);
}