differencesAsync method
Future<ListDiffs<E>>
differencesAsync(
- List<E> other, {
- String? debugName,
- DiffEquality? equality,
- ListDiffAlgorithm? algorithm,
})
Implementation
Future<ListDiffs<E>> differencesAsync(List<E> other,
{String? debugName,
DiffEquality? equality,
ListDiffAlgorithm? algorithm}) async {
equality ??= DiffEquality.diffable();
try {
algorithm ??= const MyersDiff();
final originalArgs = ListDiffArguments<E>.copied(this, other, equality);
final name = "$currentIsolateName: listDiff[${debugName ?? "-"}]";
if (isMainIsolate && this is Iterable<DiffDelegate>) {
final arguments = ListDiffArguments<DiffDelegate>.copied(
this.map((s) => (s as DiffDelegate).delegate),
other.map((s) => (s as DiffDelegate).delegate),
DiffEquality.diffable(),
id: "${originalArgs.id}.delegate",
debugName: "$debugName (delegate)",
);
final context = ListDiffContext<DiffDelegate>(algorithm, arguments,
debugName: "$debugName (delegate)");
final diff = await _runAsync(executeListDiff, context, name: name);
final undelegated = diff.undelegate<E>(originalArgs);
return undelegated;
} else {
final arguments = ListDiffArguments<E>.copied(this, other, equality);
final context =
ListDiffContext<E>(algorithm, arguments, debugName: debugName);
if (!isMainIsolate) {
_log.info("Running $debugName in $currentIsolateName:");
return executeListDiff(context);
} else {
final diff = await _runAsync(executeListDiff, context, name: name);
return diff.recast(originalArgs);
}
}
} catch (e, stack) {
_log.severe("$debugName setDiff $e", e, stack);
rethrow;
}
}