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

This commit is contained in:
just_stuff_tm authored and just-stuff-tm committed 2026-03-05 02:25:05 -05:00
1 parent dcad5c586d
commit ca5784f3f8
1 file changed
+5
+5
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();
}