Open allasca opened 10 months ago
import 'dart:async';
and
void detectUSB() async {
usbPlugin.stateUsbStream().listen((int data) async {
print('The state of USB Connected: $data');
});
}
and
void initState() async {
detectUSB();
super.initState();
}
Also, every audition should be closed this way
@override
void dispose() {
usbSubscription?.cancel();
super.dispose();
}
and
StreamSubscription? usbSubscription;
...
void detectUSB() async {
usbSubscription = usbPlugin.stateUsbStream().listen((int data) async {
print('The state of USB Connected: $data');
});
}
Thanks @beanomen4 @allasca . I will update it
result