Add post-frame callback to ensure disconnection on dispose when navigation hasn't changed

This commit is contained in:
just_stuff_tm 2026-03-02 04:55:47 -05:00 committed by just-stuff-tm
parent dcad5c586d
commit ca5784f3f8

View file

@ -68,6 +68,11 @@ class _ScannerScreenState extends State<ScannerScreen> {
void dispose() {
_connector.removeListener(_connectionListener);
unawaited(_bluetoothStateSubscription.cancel());
if (!_changedNavigation) {
WidgetsBinding.instance.addPostFrameCallback((_) {
unawaited(_connector.disconnect(manual: true));
});
}
super.dispose();
}