Skip to content

fix: Add mounted guard after async network calls in AmountScreen #67

@Delgado74

Description

@Delgado74

Summary

After awaiting network calls in lib_backup/lib/screens/11amount_screen.dart, the State.mounted flag is not re-checked before calling _showPendingSnackBar, _showSuccessSnackBar, or Navigator.of(context).popUntil. If the user navigates away while a request is in flight, these UI calls run against a disposed widget, which can cause exceptions.
Affected locations

_processLNURLPayment (~lines 291–323): after await _invoiceService.sendPaymentToLNURL — snackbar and navigation calls proceed without a mounted check.
_processLightningAddressPayment (~lines 375–409): same pattern with the Lightning Address payment call.

Suggested fix

Add an if (!mounted) return; guard immediately after each await network call and before any snackbar or navigation call. Example:

final paymentResult = await _invoiceService.sendPaymentToLNURL(...);
if (!mounted) return; // ← add this guard
// then snackbar / Navigator calls

Context

This is a pre-existing issue in the original code, not introduced by PR 

fix: Apply CodeRabbit improvements and localization fixes #61 .
Identified during review of PR
Requested by: @Delgado74

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions