differencesAsync method Null safety

Future<SetDiffs<E>> differencesAsync(
  1. Set<E> other,
  2. {bool checkEquality = true,
  3. String? debugName,
  4. required DiffEquality equality,
  5. SetDiffAlgorithm? algorithm}
)

Implementation

Future<SetDiffs<E>> differencesAsync(Set<E> other,
    {bool checkEquality = true,
    String? debugName,
    required DiffEquality equality,
    SetDiffAlgorithm? algorithm}) async {
  try {
    algorithm ??= const DefaultSetDiffAlgorithm();
    final arguments =
        SetDiffArguments<E>.copied(this, other, checkEquality, equality);
    final context =
        SetDiffContext<E>(algorithm, arguments, debugName: debugName);
    final name = "$currentIsolateName: setDiff[${debugName ?? "-"}]";

    if (isMainIsolate && this is Iterable<DiffDelegate>) {
      final delegateArgs = SetDiffArguments<DiffDelegate>.copied(
          this.map((s) => (s as DiffDelegate).delegate),
          other.map((s) => (s as DiffDelegate).delegate),
          true,
          DiffEquality.diffable());
      final context = SetDiffContext<DiffDelegate>(algorithm, delegateArgs,
          debugName: "$debugName (delegate)");
      final diff = await _runAsync(executeSetDiff, context, name: name);
      return diff.undelegate(arguments);
    } else {
      final diff = await _runAsync(executeSetDiff, context, name: name);
      return diff.recast<E>(arguments);
    }
  } catch (e, stack) {
    _log.severe("$debugName setDiff $e", e, stack);
    rethrow;
  }
}