operator + method

DataRefModel operator +(
  1. DataRefModel other
)

Adds two DataRefModel objects.

Implementation

DataRefModel operator +(DataRefModel other) {
  final temp = [...this.doc, ...other.doc];
  if (temp.isNotEmpty) {
    final length = temp.length;
    if (length.isEven) {
      final collection = temp.sublist(0, length - 1);
      final id = temp.last;
      return DataRefModel(
        id: id,
        collection: collection,
      );
    } else {
      final collection = temp;
      return DataRefModel(
        id: null,
        collection: collection,
      );
    }
  } else {
    return const DataRefModel();
  }
}