when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>(
  1. TResult $default(
    1. String? id,
    2. String name,
    3. MapSource source,
    4. String? rasterServerLight,
    5. String? rasterServerDark,
    6. String? googleToken,
    7. List<GoogleMapLayer>? googleLayers,
    8. String? mapboxToken,
    9. List<MapboxStyle>? mapboxLayers,
    10. String? mapboxCustomUsername,
    11. String? mapboxCustomStyleId,
    12. String? hereToken,
    13. List<HereStyle>? hereLayers,
    14. String attributionUrl,
    15. String? attributionUrlDark,
    16. double attributionWidth,
    17. double attributionHeight,
    18. List<String> appsIds,
    )
)

A switch-like method, using callbacks.

As opposed to map, this offers destructuring. It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case Subclass2(:final field2):
    return ...;
}

Implementation

@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String? id,  String name, @JsonKey(unknownEnumValue: MapSource.custom)  MapSource source,  String? rasterServerLight,  String? rasterServerDark,  String? googleToken, @JsonKey(unknownEnumValue: GoogleMapLayer.roadmap)  List<GoogleMapLayer>? googleLayers,  String? mapboxToken, @JsonKey(unknownEnumValue: MapboxStyle.navigation)  List<MapboxStyle>? mapboxLayers,  String? mapboxCustomUsername,  String? mapboxCustomStyleId,  String? hereToken, @JsonKey(unknownEnumValue: HereStyle.lite)  List<HereStyle>? hereLayers,  String attributionUrl,  String? attributionUrlDark,  double attributionWidth,  double attributionHeight,  List<String> appsIds)  $default,) {final _that = this;
switch (_that) {
case _MapLayerInput():
return $default(_that.id,_that.name,_that.source,_that.rasterServerLight,_that.rasterServerDark,_that.googleToken,_that.googleLayers,_that.mapboxToken,_that.mapboxLayers,_that.mapboxCustomUsername,_that.mapboxCustomStyleId,_that.hereToken,_that.hereLayers,_that.attributionUrl,_that.attributionUrlDark,_that.attributionWidth,_that.attributionHeight,_that.appsIds);case _:
  throw StateError('Unexpected subclass');

}
}