startScan method
开始扫描 在Flutter中定义Timer超时
Implementation
Future<bool> startScan({int timeout = 10000}) async {
if (isScanning) {
return false;
}
_setEventFor();
bool success = await BleAPI.instance.startScan();
if (success) {
isScanning = true;
}
if (_timer != null && _timer!.isActive) {
_timer!.cancel();
}
_createTimer(timeout);
return success;
}