copy method

Creates a copy of this builder with all its components.

The returned builder is a new instance with the same components, but modifications to either builder won't affect the other.

Example:

final original = MessageBuilder()
  ..addText('Original content');

final duplicate = original.copy()
  ..addText('Additional content');

// original still only has one text component
// duplicate has two text components

See also:

  • copyWith to create a copy combined with another builder

Implementation

MessageBuilder copy() {
  return MessageBuilder().._components.addAll(_components);
}