start static method
- LeakTrackingConfig config = const LeakTrackingConfig(),
- bool resetIfAlreadyStarted = false,
Configures leak tracking for the application.
The leak tracking will function only for debug/profile/developer mode. See usage guidance at https://github.com/dart-lang/leak_tracker.
If resetIfAlreadyStarted
is true and leak tracking is already on,
the tracking will be reset with new configuration.
If resetIfAlreadyStarted
is false and leak tracking is already on,
StateError will be thrown.
Implementation
static void start({
LeakTrackingConfig config = const LeakTrackingConfig(),
bool resetIfAlreadyStarted = false,
}) {
assert(() {
if (_leakTracker != null) {
if (!resetIfAlreadyStarted) {
throw StateError('Leak tracking is already enabled.');
}
stop();
}
final leakTracker = _leakTracker = LeakTracker(config, _phase);
_leakProvider.value = WeakReference(leakTracker.objectTracker);
if (config.notifyDevTools) {
// While [leakTracker] will push summary leak notifications to DevTools,
// DevTools may request leak details from
// the application via integration.
// That's why it needs [_leakProvider].
initializeDevToolsIntegration(_leakProvider);
} else {
registerLeakTrackingServiceExtension();
}
return true;
}());
}