withTracked method

  1. @useResult
LeakTesting withTracked({
  1. List<String> experimentalNotGCed = const [],
  2. List<String> notDisposed = const [],
  3. List<String> classes = const [],
  4. bool experimentalAllNotGCed = false,
  5. bool allNotDisposed = false,
  6. bool createdByTestHelpers = false,
})

Returns copy of settings with reduced ignore lists.

Items in classes will be removed from all ignore lists.

Implementation

@useResult
LeakTesting withTracked({
  List<String> experimentalNotGCed = const [],
  List<String> notDisposed = const [],
  List<String> classes = const [],
  bool experimentalAllNotGCed = false,
  bool allNotDisposed = false,
  bool createdByTestHelpers = false,
}) {
  var newNotGCed = ignoredLeaks.experimentalNotGCed
      .track([...experimentalNotGCed, ...classes]);
  if (experimentalAllNotGCed) {
    newNotGCed = newNotGCed.copyWith(ignoreAll: false);
  }

  var newNotDisposed =
      ignoredLeaks.notDisposed.track([...notDisposed, ...classes]);
  if (allNotDisposed) {
    newNotDisposed = newNotDisposed.copyWith(ignoreAll: false);
  }

  final result = copyWith(
    ignoredLeaks: IgnoredLeaks(
      experimentalNotGCed: newNotGCed,
      notDisposed: newNotDisposed,
      createdByTestHelpers:
          ignoredLeaks.createdByTestHelpers && !createdByTestHelpers,
      testHelperExceptions: ignoredLeaks.testHelperExceptions,
    ),
  );
  return result;
}