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

View file

@ -167,7 +167,8 @@ class _LoginOnOtherDeviceState extends State<LoginOnOtherDevice> {
ScaffoldMessenger.of(context).snack('Logged in successfully!'.i18n); ScaffoldMessenger.of(context).snack('Logged in successfully!'.i18n);
} }
void _cancel() async { @override
void dispose() async {
if (_step2) { if (_step2) {
final hash = final hash =
Hmac(sha512, key.bytes).convert(utf8.encode(_code)).toString(); Hmac(sha512, key.bytes).convert(utf8.encode(_code)).toString();
@ -175,7 +176,7 @@ class _LoginOnOtherDeviceState extends State<LoginOnOtherDevice> {
data: jsonEncode({'_': 'cancel', 'hash': hash})); data: jsonEncode({'_': 'cancel', 'hash': hash}));
} }
Navigator.pop(context); super.dispose();
} }
@override @override
@ -237,12 +238,14 @@ class _LoginOnOtherDeviceState extends State<LoginOnOtherDevice> {
]), ]),
), ),
actions: [ actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text('Cancel'.i18n)),
if (!_step2) if (!_step2)
TextButton( TextButton(
onPressed: _loading ? null : _doHandshake, onPressed: _loading ? null : _doHandshake,
child: Text('Login'.i18n), child: Text('Login'.i18n),
), ),
TextButton(onPressed: _cancel, child: Text('Cancel'.i18n))
], ],
); );
} }