when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>(
  1. TResult $default(
    1. String name,
    2. TenvioPropertyDataType dataType,
    3. bool isRequired,
    4. List<String> choices,
    5. double? minValue,
    6. double? maxValue,
    7. int? minLength,
    8. int? maxLength,
    9. int? maxFileSize,
    10. dynamic defaultValue,
    )
)

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 name, @TenvioPropertyDataTypeConverter()  TenvioPropertyDataType dataType,  bool isRequired,  List<String> choices,  double? minValue,  double? maxValue,  int? minLength,  int? maxLength,  int? maxFileSize,  dynamic defaultValue)  $default,) {final _that = this;
switch (_that) {
case _TenvioCustomPropertyInput():
return $default(_that.name,_that.dataType,_that.isRequired,_that.choices,_that.minValue,_that.maxValue,_that.minLength,_that.maxLength,_that.maxFileSize,_that.defaultValue);case _:
  throw StateError('Unexpected subclass');

}
}