From 15490444a9b52077ace92ec1323f740f9981d928 Mon Sep 17 00:00:00 2001 From: Pato05 Date: Mon, 12 Feb 2024 03:46:39 +0100 Subject: [PATCH] send cancel on widget dispose --- lib/ui/login_on_other_device.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/ui/login_on_other_device.dart b/lib/ui/login_on_other_device.dart index 321c409..7440540 100644 --- a/lib/ui/login_on_other_device.dart +++ b/lib/ui/login_on_other_device.dart @@ -167,7 +167,8 @@ class _LoginOnOtherDeviceState extends State { ScaffoldMessenger.of(context).snack('Logged in successfully!'.i18n); } - void _cancel() async { + @override + void dispose() async { if (_step2) { final hash = Hmac(sha512, key.bytes).convert(utf8.encode(_code)).toString(); @@ -175,7 +176,7 @@ class _LoginOnOtherDeviceState extends State { data: jsonEncode({'_': 'cancel', 'hash': hash})); } - Navigator.pop(context); + super.dispose(); } @override @@ -237,12 +238,14 @@ class _LoginOnOtherDeviceState extends State { ]), ), actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: Text('Cancel'.i18n)), if (!_step2) TextButton( onPressed: _loading ? null : _doHandshake, child: Text('Login'.i18n), ), - TextButton(onPressed: _cancel, child: Text('Cancel'.i18n)) ], ); }