copyWith method

FeatureCollection<E> copyWith({
  1. List<E>? features,
  2. Map<String, dynamic>? custom,
})

Copy this feature collection with optional features and custom properties.

When a new list of features is given, then the returned collection has bounds set to null.

Implementation

FeatureCollection<E> copyWith({
  List<E>? features,
  Map<String, dynamic>? custom,
}) {
  if (features != null) {
    final type = resolveCoordTypeFrom(collection: features);
    return FeatureCollection<E>._(
      features,
      type,
      custom: custom ?? this.custom,
    );
  } else if (custom != null) {
    return FeatureCollection<E>._(
      this.features,
      this.coordType,
      custom: custom,
      bounds: bounds,
    );
  } else {
    // ignore: avoid_returning_this
    return this;
  }
}