when<TResult extends Object?> method
TResult
when<TResult extends Object?>()
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');
}
}