maybeWhen<T> method

  1. @Deprecated('Use a pattern matching selection pattern (such as `if case` or `switch`) ' 'instead. ' 'This is now a redundant method as the `BaseRegion` inheritance tree is ' 'sealed and modern Dart supports the intended purpose of this natively. ' 'This feature was deprecated in v10, and will be removed in a future ' 'version.')
T? maybeWhen<T>({
  1. T rectangle(
    1. RectangleRegion rectangle
    )?,
  2. T circle(
    1. CircleRegion circle
    )?,
  3. T line(
    1. LineRegion line
    )?,
  4. T customPolygon(
    1. CustomPolygonRegion customPolygon
    )?,
  5. T multi(
    1. MultiRegion multi
    )?,
})

Output a value of type T the type of this region

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

Implementation

@Deprecated(
  'Use a pattern matching selection pattern (such as `if case` or `switch`) '
  'instead. '
  'This is now a redundant method as the `BaseRegion` inheritance tree is '
  'sealed and modern Dart supports the intended purpose of this natively. '
  'This feature was deprecated in v10, and will be removed in a future '
  'version.',
)
T? maybeWhen<T>({
  T Function(RectangleRegion rectangle)? rectangle,
  T Function(CircleRegion circle)? circle,
  T Function(LineRegion line)? line,
  T Function(CustomPolygonRegion customPolygon)? customPolygon,
  T Function(MultiRegion multi)? multi,
}) =>
    switch (this) {
      RectangleRegion() => rectangle?.call(this as RectangleRegion),
      CircleRegion() => circle?.call(this as CircleRegion),
      LineRegion() => line?.call(this as LineRegion),
      CustomPolygonRegion() =>
        customPolygon?.call(this as CustomPolygonRegion),
      MultiRegion() => multi?.call(this as MultiRegion),
    };