dispose method
销毁时调用
Implementation
@override
void dispose() async {
super.dispose();
clearStateChangeListener();
if (_eventSubscription != null) {
_eventSubscription!.cancel();
_eventSubscription = null;
}
if (isScanning) {
await BleAPI.instance.stopScan();
}
if (_timer != null && _timer!.isActive) {
_timer!.cancel();
_timer = null;
}
}