when<TResult extends Object?> method
- @optionalTypeArgs
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( Map<String, VersionConstraint?>? environment, String? publishTo, Uri? repository, Uri? issueTracker, List<String>? topics, String? documentation, String? resolution, Map<String, Dependency>? dependencies) $default,) {final _that = this;
switch (_that) {
case _Catalog():
return $default(_that.environment,_that.publishTo,_that.repository,_that.issueTracker,_that.topics,_that.documentation,_that.resolution,_that.dependencies);case _:
throw StateError('Unexpected subclass');
}
}