Add post-frame callback to ensure disconnection on dispose when navigation hasn't changed
This commit is contained in:
1 parent
dcad5c586d
commit
ca5784f3f8
1 file changed
+5
@@ -68,6 +68,11 @@ class _ScannerScreenState extends State<ScannerScreen> {
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
_connector.removeListener(_connectionListener);
|
_connector.removeListener(_connectionListener);
|
||||||
unawaited(_bluetoothStateSubscription.cancel());
|
unawaited(_bluetoothStateSubscription.cancel());
|
||||||
|
if (!_changedNavigation) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
unawaited(_connector.disconnect(manual: true));
|
||||||
|
});
|
||||||
|
}
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user