maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String id,
    2. String name,
    3. String ident,
    4. String? flespiToken,
    5. String? modelId,
    6. Model? model,
    7. String? protocolId,
    8. InboundProtocol? protocol,
    9. Map<String, dynamic>? additionalFields,
    10. String? qrCode,
    11. String? linkQr,
    12. List<DeviceCommand>? commands,
    13. List<Access>? access,
    14. DeviceTelemetry? telemetry,
    15. String? visionProfileId,
    16. VisionProfile? visionProfile,
    17. PhoneNumber? phone,
    18. ModbusConfig? modbus,
    19. bool? isSuspended,
    20. HwModel? hwModel,
    21. String? hwModelId,
    22. String? macAddress,
    23. Map<String, dynamic>? configParams,
    24. Duration? visionCaptureThreshold,
    25. List<Device>? peripherals,
    26. String? localIpAddress,
    )?, {
  2. required TResult orElse(),
})

A variant of when that fallback to an orElse callback.

It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case _:
    return orElse();
}

Implementation

@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id,  String name,  String ident,  String? flespiToken,  String? modelId,  Model? model,  String? protocolId,  InboundProtocol? protocol,  Map<String, dynamic>? additionalFields,  String? qrCode,  String? linkQr,  List<DeviceCommand>? commands,  List<Access>? access,  DeviceTelemetry? telemetry,  String? visionProfileId,  VisionProfile? visionProfile,  PhoneNumber? phone,  ModbusConfig? modbus,  bool? isSuspended,  HwModel? hwModel,  String? hwModelId,  String? macAddress,  Map<String, dynamic>? configParams, @DurationConverter()  Duration? visionCaptureThreshold,  List<Device>? peripherals,  String? localIpAddress)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Device() when $default != null:
return $default(_that.id,_that.name,_that.ident,_that.flespiToken,_that.modelId,_that.model,_that.protocolId,_that.protocol,_that.additionalFields,_that.qrCode,_that.linkQr,_that.commands,_that.access,_that.telemetry,_that.visionProfileId,_that.visionProfile,_that.phone,_that.modbus,_that.isSuspended,_that.hwModel,_that.hwModelId,_that.macAddress,_that.configParams,_that.visionCaptureThreshold,_that.peripherals,_that.localIpAddress);case _:
  return orElse();

}
}