diff<E> static method

Future<List<Diff>> diff<E>(
  1. List<E> newList,
  2. List<E> oldList, {
  3. ItemDiffUtil<E>? areItemsTheSame,
  4. bool? spawnIsolate,
})

Implementation

static Future<List<Diff>> diff<E>(
  List<E> newList,
  List<E> oldList, {
  ItemDiffUtil<E>? areItemsTheSame,
  bool? spawnIsolate,
}) {
  eq = (a, b) => areItemsTheSame?.call(a, b) ?? a == b;
  cq = (a, b) => false;

  final args = _DiffArguments<E>(oldList, newList);

  // We can significantly improve the performance by not spawning a new
  // isolate for shorter lists.
  spawnIsolate ??= (newList.length * oldList.length) > isolateThreshold;
  if (spawnIsolate) {
    return compute(_myersDiff, args);
  }

  return Future.value(_myersDiff(args));
}