when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>(
  1. TResult $default(
    1. String id,
    2. String token,
    3. LocatorMqttConfig? mqttConfig,
    4. List<Asset>? assets,
    5. List<String>? assetsIds,
    6. List<Geofence>? geofences,
    7. List<String>? geofencesIds,
    8. List<Trigger>? triggers,
    9. List<String>? triggersIds,
    10. DateTime? expiresAt,
    11. User? expiredBy,
    12. String? expiredById,
    13. bool? isExpired,
    14. DateTime createdAt,
    15. User? createdBy,
    16. String? createdById,
    17. DateTime updatedAt,
    18. User? updatedBy,
    19. String? updatedById,
    20. RegisteredApp? customization,
    21. String? customizationId,
    )
)

A switch-like method, using callbacks.

As opposed to map, this offers destructuring. It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case Subclass2(:final field2):
    return ...;
}

Implementation

@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id,  String token,  LocatorMqttConfig? mqttConfig,  List<Asset>? assets,  List<String>? assetsIds,  List<Geofence>? geofences,  List<String>? geofencesIds,  List<Trigger>? triggers,  List<String>? triggersIds, @TimestampOrNullConverter()  DateTime? expiresAt,  User? expiredBy,  String? expiredById,  bool? isExpired, @TimestampConverter()  DateTime createdAt,  User? createdBy,  String? createdById, @TimestampConverter()  DateTime updatedAt,  User? updatedBy,  String? updatedById,  RegisteredApp? customization,  String? customizationId)  $default,) {final _that = this;
switch (_that) {
case _Locator():
return $default(_that.id,_that.token,_that.mqttConfig,_that.assets,_that.assetsIds,_that.geofences,_that.geofencesIds,_that.triggers,_that.triggersIds,_that.expiresAt,_that.expiredBy,_that.expiredById,_that.isExpired,_that.createdAt,_that.createdBy,_that.createdById,_that.updatedAt,_that.updatedBy,_that.updatedById,_that.customization,_that.customizationId);case _:
  throw StateError('Unexpected subclass');

}
}