LeakTesting class

leak_tracker settings for tests.

Set LeakTesting.settings, to change default leak tracking settings for tests. Set it for package or folder in flutter_test_config.dart and for a test file in setUpAll.

If you update the settings for a group, remember the original value to a local variable and restore it in tearDownAll for the group.

Use methods that return adjusted LeakTesting.settings to customize default for an individual test:

    'initialTimerDuration falls within limit',
    leakTracking: LeakTesting.settings.withIgnoredAll(),
    (WidgetTester tester) async {

If LeakTesting.settings are updated during a test run, the new value will be used for the next test.



baselining MemoryBaselining
Settings to measure the test's memory footprint.
hashCode int
The hash code for this object.
no setteroverride
ignore bool
If true, leak tracking is paused.
ignoredLeaks IgnoredLeaks
Leaks to ignore.
leakDiagnosticConfig LeakDiagnosticConfig
Defines which diagnostics information to collect.
runtimeType Type
A representation of the runtime type of the object.
no setterinherited


copyWith({IgnoredLeaks? ignoredLeaks, LeakDiagnosticConfig? leakDiagnosticConfig, bool? ignore, MemoryBaselining? baselining}) LeakTesting
Creates a copy of this object with the given fields replaced with the new values.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
toString() String
A string representation of this object.
withCreationStackTrace() LeakTesting
Copies with enabled collection of creation stack trace.
withDisposalStackTrace() LeakTesting
Copies with enabled collection of disposal stack trace.
withIgnored({Map<String, int?> notGCed = const {}, bool allNotGCed = false, Map<String, int?> notDisposed = const {}, bool allNotDisposed = false, List<String> classes = const [], bool createdByTestHelpers = false, List<RegExp> testHelperExceptions = const []}) LeakTesting
Returns copy of settings with extended ignore lists.
withIgnoredAll() LeakTesting
Copies with ignore set to true.
withRetainingPath() LeakTesting
Creates copy of settings, that collects the retaining path for not GCed objects.
withTracked({List<String> experimentalNotGCed = const [], List<String> notDisposed = const [], List<String> classes = const [], bool experimentalAllNotGCed = false, bool allNotDisposed = false, bool createdByTestHelpers = false}) LeakTesting
Returns copy of settings with reduced ignore lists.
withTrackedAll() LeakTesting
Copies with ignore set to false.


operator ==(Object other) bool
The equality operator.

Static Properties

collectedLeaksReporter LeaksCallback
Handler for memory leaks found in tests.
getter/setter pair
enabled bool
If true, leak tracking is enabled.
no setter
settings LeakTesting
Current configuration for leak tracking.
getter/setter pair

Static Methods

enable() → void
Invoke in flutter_test_config.dart to enable leak tracking.