debounceClose method

void debounceClose()

Implementation

void debounceClose() {
  print("debounceClose : ${this.widget.isWidget}");

  if(this.widget.isWidget == true) {
    // this.widget.onCloseWidget!();
    widget.closeController.bootpayClose(this.widget.onCloseWidget);
  } else {
    // Non-widget mode: wrap onClose to also pop the navigator
    widget.closeController.bootpayClose(() {
      // Call user's onClose callback first
      if(this.widget.onClose != null) {
        this.widget.onClose!();
      }
      // Then pop the navigator to dismiss Bootpay UI
      // README 는 onClose 에서 Bootpay().dismiss(context) 를 부르라고 안내한다. 그걸로 이미 닫혔는데
      // 여기서 또 pop 하면 호출한 화면까지 닫히므로, 이 route 가 아직 맨 위일 때만 pop 한다.
      if(context.mounted && (ModalRoute.of(context)?.isCurrent ?? false)) {
        Navigator.of(context).pop();
      }
    });
  }
  // widget.paymentResult = BootpayPaymentResult.NONE;
  // widget.closeController.bootpayClose(this.widget.onClose);
}