when<TResult extends Object?> method
- @optionalTypeArgs
- required TResult internal(
- GlobalOptions globalOptions,
- String cacheDir,
- String patchDir
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?>({required TResult Function( GlobalOptions globalOptions, String cacheDir, String patchDir) internal,}) {final _that = this;
switch (_that) {
case _GlobalPatchOptions():
return internal(_that.globalOptions,_that.cacheDir,_that.patchDir);case _:
throw StateError('Unexpected subclass');
}
}