Skip to content

Commit ce80787

Browse files
authored
Merge pull request #155 from Prime-Holding/fix/pin-code-key-set-state-error
Fix pin code key throwing a setState error
2 parents 842d858 + 4b56e1e commit ce80787

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

  • packages/widget_toolkit_pin/lib/src/lib_pin_code_with_biometrics/ui_components

packages/widget_toolkit_pin/lib/src/lib_pin_code_with_biometrics/ui_components/pin_code_key.dart

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ class _PinCodeKeyState extends State<PinCodeKey> {
4848
onTapDown: widget.isLoading
4949
? null
5050
: (_) async {
51-
setState(() {
52-
isPressed = true;
53-
});
51+
if (mounted) {
52+
setState(() {
53+
isPressed = true;
54+
});
55+
}
56+
5457
if (widget.isFingerScan || widget.isFaceScan) {
5558
await Future.delayed(widget.tintDuration);
5659
}
@@ -109,9 +112,11 @@ class _PinCodeKeyState extends State<PinCodeKey> {
109112
calculateKeyboardButtonSize(context);
110113

111114
void _cancelPress() {
112-
setState(() {
113-
isPressed = false;
114-
});
115+
if (mounted) {
116+
setState(() {
117+
isPressed = false;
118+
});
119+
}
115120
}
116121

117122
void _delayedButtonRelease() async {

0 commit comments

Comments
 (0)