maybeWhen<T> method

T? maybeWhen<T>({
  1. T rectangle(
    1. DownloadableRegion<RectangleRegion> rectangle
    )?,
  2. T circle(
    1. DownloadableRegion<CircleRegion> circle
    )?,
  3. T line(
    1. DownloadableRegion<LineRegion> line
    )?,
  4. T customPolygon(
    1. DownloadableRegion<CustomPolygonRegion> customPolygon
    )?,
  5. T multi(
    1. DownloadableRegion<MultiRegion> multi
    )?,
})

Output a value of type T dependent on originalRegion and its type R

If the specified method is not defined for the type of region which this region is, null will be returned.

Implementation

T? maybeWhen<T>({
  T Function(DownloadableRegion<RectangleRegion> rectangle)? rectangle,
  T Function(DownloadableRegion<CircleRegion> circle)? circle,
  T Function(DownloadableRegion<LineRegion> line)? line,
  T Function(DownloadableRegion<CustomPolygonRegion> customPolygon)?
      customPolygon,
  T Function(DownloadableRegion<MultiRegion> multi)? multi,
}) =>
    switch (originalRegion) {
      RectangleRegion() => rectangle?.call(cast()),
      CircleRegion() => circle?.call(cast()),
      LineRegion() => line?.call(cast()),
      CustomPolygonRegion() => customPolygon?.call(cast()),
      MultiRegion() => multi?.call(cast()),
    };