operator + method

Book operator +(
  1. Book other
)

Implementation

Book operator +(Book other) {
  List<Author> mergedAuthors = [];
  mergedAuthors.addAll(authors);
  mergedAuthors.addAll(other.authors);
  mergedAuthors = mergedAuthors.toSet().toList();

  ChapterList? mergedAppendices;
  if (appendices != null) {
    if (other.appendices != null) {
      mergedAppendices = appendices! + other.appendices!;
    } else {
      mergedAppendices = appendices;
    }
  } else {
    mergedAppendices = other.appendices;
  }

  return Book(
      heading: heading,
      authors: mergedAuthors,
      chapters: chapters + other.chapters,
      appendices: mergedAppendices);
}