copyWith method

Node copyWith({
  1. String? id,
  2. String? root,
  3. String? previous,
  4. String? pathHash,
  5. Map<String, dynamic>? content,
})

Create a copy of this node with updated fields

Implementation

Node copyWith({
  String? id,
  String? root,
  String? previous,
  String? pathHash,
  Map<String, dynamic>? content,
}) {
  final newContent = NodeContent();
  final contentToUse = content ?? contentMap;
  contentToUse.forEach((key, value) {
    newContent[key] = value;
  });

  return Node(
    id: id ?? this.id,
    root: root ?? this.root,
    previous: previous ?? this.previous,
    pathHash: pathHash ?? this.pathHash,
    content: newContent,
  );
}