when<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 when<T>({
  1. required T rectangle(
    1. RectangleRegion rectangle
    ),
  2. required T circle(
    1. CircleRegion circle
    ),
  3. required T line(
    1. LineRegion line
    ),
  4. required T customPolygon(
    1. CustomPolygonRegion customPolygon
    ),
  5. required T multi(
    1. MultiRegion multi
    ),
})

Output a value of type T the type of this region

Requires all region types to have a defined handler. See maybeWhen for the equivalent where this is not required.

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 when<T>({
  required T Function(RectangleRegion rectangle) rectangle,
  required T Function(CircleRegion circle) circle,
  required T Function(LineRegion line) line,
  required T Function(CustomPolygonRegion customPolygon) customPolygon,
  required T Function(MultiRegion multi) multi,
}) =>
    maybeWhen(
      rectangle: rectangle,
      circle: circle,
      line: line,
      customPolygon: customPolygon,
      multi: multi,
    )!;