differencesAsync method
Future<MapDiffs<K, V>>
differencesAsync(
- Map<K, V> other, {
- bool checkValues = true,
- String? debugName,
- DiffEquality? keyEquality,
- DiffEquality? valueEquality,
- MapDiffAlgorithm? algorithm,
})
Implementation
Future<MapDiffs<K, V>> differencesAsync(
Map<K, V> other, {
bool checkValues = true,
String? debugName,
DiffEquality? keyEquality,
DiffEquality? valueEquality,
MapDiffAlgorithm? algorithm,
}) async {
try {
algorithm ??= const DefaultMapDiffAlgorithm();
final args = MapDiffArguments<K, V>.copied(this, other,
checkValues: checkValues,
keyEquality: keyEquality,
valueEquality: valueEquality);
final context =
MapDiffContext(algorithm, args, isTimed: true, debugName: debugName);
final name = "$currentIsolateName: setDiff[${debugName ?? "-"}]";
if (this is Map<K, DiffDelegate>) {
final delegateArgs = MapDiffArguments<K, DiffDelegate>.copied(
this
.valuesNotNull()
.map((k, s) => MapEntry(k, (s as DiffDelegate).delegate)),
other
.valuesNotNull()
.map((k, s) => MapEntry(k, (s as DiffDelegate).delegate)),
checkValues: checkValues,
keyEquality: keyEquality,
valueEquality: const DiffEquality.diffable(),
);
final context = MapDiffContext<K, DiffDelegate>(algorithm, delegateArgs,
debugName: "$debugName (delegate)");
final diff = await _runAsync(executeMapDiff, context, name: name);
return diff.undelegate<K, V>(args);
} else {
if (!isMainIsolate) {
return executeMapDiff(context);
} else {
final diff = await _runAsync(executeMapDiff, context, name: name);
return diff.recast<K, V>(args);
}
}
} catch (e, stack) {
_log.severe("$debugName setDiff $e", e, stack);
rethrow;
}
}