start static method

void start({
  1. LeakTrackingConfig config = const LeakTrackingConfig(),
  2. 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();
    }

    _leakTracker = LeakTracker(config, _phase);

    return true;
  }());
}