whenOrNull<TResult extends Object?> method
TResult?
whenOrNull<TResult extends Object?>()
A variant of when that fallback to returning null
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case _:
return null;
}
Implementation
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( double scrollOffsetX, double scrollOffsetY, double viewportWidth, double viewportHeight, int firstVisibleRow, int lastVisibleRow, int firstVisibleColumn, int lastVisibleColumn)? $default,) {final _that = this;
switch (_that) {
case _ViewportState() when $default != null:
return $default(_that.scrollOffsetX,_that.scrollOffsetY,_that.viewportWidth,_that.viewportHeight,_that.firstVisibleRow,_that.lastVisibleRow,_that.firstVisibleColumn,_that.lastVisibleColumn);case _:
return null;
}
}