flutter_blue插件调用characteristic.read方法报错
Exception has occurred.
PlatformException (PlatformException(read_characteristic_error, unknown reason, may occur if readCharacteristic was called before last read finished., null))
解决办法
- 在read之前判断有没有read权限
if(characteristic.properties.read){
c.read();
}
- 使用listen监听
await characteristic.setNotifyValue(true);
characteristic.value.listen((event) {
// do
});
本文解决了使用Flutter_Blue插件时遇到的characteristic.read方法调用失败的问题。通过检查读取权限并在使用前等待上一次读取操作完成来避免错误的发生。
1823

被折叠的 条评论
为什么被折叠?



