when<R> method

R when<R>({
  1. required R ifSimpleFillSymbol(
    1. SimpleFillSymbol symbol
    ),
  2. required R ifSimpleMarkerSymbol(
    1. SimpleMarkerSymbol symbol
    ),
  3. required R ifPictureMarkerSymbol(
    1. PictureMarkerSymbol symbol
    ),
  4. required R ifSimpleLineSymbol(
    1. SimpleLineSymbol symbol
    ),
  5. required R ifMeshSymbol3D(
    1. MeshSymbol3D symbol
    ),
})

Implementation

R when<R>({
  required R Function(SimpleFillSymbol symbol) ifSimpleFillSymbol,
  required R Function(SimpleMarkerSymbol symbol) ifSimpleMarkerSymbol,
  required R Function(PictureMarkerSymbol symbol) ifPictureMarkerSymbol,
  required R Function(SimpleLineSymbol symbol) ifSimpleLineSymbol,
  required R Function(MeshSymbol3D symbol) ifMeshSymbol3D,
}) {
  final self = this;
  if (self is SimpleFillSymbol) {
    return ifSimpleFillSymbol(self);
  }
  if (self is SimpleMarkerSymbol) {
    return ifSimpleMarkerSymbol(self);
  }
  if (self is PictureMarkerSymbol) {
    return ifPictureMarkerSymbol(self);
  }
  if (self is SimpleLineSymbol) {
    return ifSimpleLineSymbol(self);
  }
  if (self is MeshSymbol3D) {
    return ifMeshSymbol3D(self);
  }

  throw Exception("Unknown Symbol: $self");
}