attachLifecycleObserver method

void attachLifecycleObserver()

Implementation

void attachLifecycleObserver() {
  WidgetsBinding.instance.removeObserver(this); // avoid duplicate registration
  WidgetsBinding.instance.addObserver(this);
  // Reset succeeded flag here — this marks the start of a new payment
  // session. Resetting in disconnect() was too early: it allowed lifecycle
  // resume events (e.g. notification swipe, brief background) to re-trigger
  // success navigation for the already-completed transaction.
  _paymentSucceeded = false;
}