copyWith method

  1. @override
TextNode copyWith({
  1. String? type = 'text',
  2. Iterable<Node>? children,
  3. Attributes? attributes,
  4. Delta? delta,
  5. String? id,
})
override

Implementation

@override
TextNode copyWith({
  String? type = 'text',
  Iterable<Node>? children,
  Attributes? attributes,
  Delta? delta,
  String? id,
}) {
  final textNode = TextNode(
    children: children ?? [],
    attributes: attributes ?? this.attributes,
    delta: delta ?? this.delta,
  );
  if (children == null && this.children.isNotEmpty) {
    for (final child in this.children) {
      textNode._children.add(
        child.copyWith()..parent = textNode,
      );
    }
  }
  return textNode;
}