dvStartAppLifecycleBridge function

void dvStartAppLifecycleBridge()

Starts reporting the platform's application lifecycle on DV.lifecycle.app.

Idempotent. A second observer over the same binding would report every transition twice, and a listener counting them would see each state arrive as many times as something called this.

Ensures the binding rather than assuming it. The generated runtime calls this from configureDartvelRuntime, which runs while the router is being built -- before runApp, and therefore before runApp would have initialised anything. Reading WidgetsBinding.instance there throws, the application never reaches its first frame, and what that looked like was a site build capturing nothing: "Captured 0 of 4 routes", reported as resource pressure because that is the usual cause.

Implementation

void dvStartAppLifecycleBridge() {
  if (_observer != null) return;
  final _DVAppLifecycleObserver observer = _DVAppLifecycleObserver();
  _observer = observer;
  WidgetsFlutterBinding.ensureInitialized().addObserver(observer);
}