Add post-frame callback to disconnect USB transport on dispose if not navigated to contacts

This commit is contained in:
just_stuff_tm authored and just-stuff-tm committed 2026-03-05 02:25:05 -05:00
1 parent f39a22668e
commit a0feb129e1
1 file changed
+7
+7
View File
@@ -74,6 +74,13 @@ class _UsbScreenState extends State<UsbScreen> {
@override
void dispose() {
_connector.removeListener(_connectionListener);
if (!_navigatedToContacts &&
_connector.activeTransport == MeshCoreTransportType.usb &&
_connector.state != MeshCoreConnectionState.disconnected) {
WidgetsBinding.instance.addPostFrameCallback((_) {
unawaited(_connector.disconnect(manual: true));
});
}
super.dispose();
}