copyWith method

OsmElement copyWith({
  1. Map<String, String>? tags,
  2. int? id,
  3. int? version,
  4. LatLng? center,
  5. Geometry? geometry,
  6. IsMember? isMember,
  7. List<int>? nodes,
  8. Map<int, LatLng>? nodeLocations,
  9. bool currentTimestamp = false,
  10. bool clearMembers = false,
})

Implementation

OsmElement copyWith(
    {Map<String, String>? tags,
    int? id,
    int? version,
    LatLng? center,
    Geometry? geometry,
    IsMember? isMember,
    List<int>? nodes,
    Map<int, LatLng>? nodeLocations,
    bool currentTimestamp = false,
    bool clearMembers = false}) {
  return OsmElement(
    id: id != null ? OsmId(this.id.type, id) : this.id,
    version: version ?? this.version,
    timestamp: currentTimestamp ? DateTime.now().toUtc() : timestamp,
    downloaded: downloaded,
    tags: tags ?? this.tags,
    center: center ?? this.center,
    geometry: geometry ?? this.geometry,
    nodes: clearMembers ? null : (nodes ?? this.nodes),
    nodeLocations: clearMembers || (nodeLocations?.isEmpty ?? false)
        ? null
        : (nodeLocations ?? this.nodeLocations),
    members: clearMembers ? null : members,
    isMember: isMember ?? this.isMember,
  );
}