send cancel on widget dispose

This commit is contained in:
Pato05 2024-02-12 03:46:39 +01:00
parent b8f0bb2140
commit 15490444a9
No known key found for this signature in database
GPG Key ID: ED4C6F9C3D574FB6
1 changed files with 6 additions and 3 deletions

View File

@ -167,7 +167,8 @@ class _LoginOnOtherDeviceState extends State<LoginOnOtherDevice> {
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<LoginOnOtherDevice> {
data: jsonEncode({'_': 'cancel', 'hash': hash}));
}
Navigator.pop(context);
super.dispose();
}
@override
@ -237,12 +238,14 @@ class _LoginOnOtherDeviceState extends State<LoginOnOtherDevice> {
]),
),
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))
],
);
}