mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
Add post-frame callback to disconnect USB transport on dispose if not navigated to contacts
This commit is contained in:
parent
f39a22668e
commit
a0feb129e1
1 changed files with 7 additions and 0 deletions
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue