[英]Flutter How can I check if my device is connected to another device with Bluetooth or not
[英]Flutter how to check if there is a device connected to my device via bluetooth
我正在編寫一個使用藍牙連接的 flutter 應用程序。 我想知道我的設備是否通過藍牙連接到另一台設備。 我想問一下是否有類似藍牙的互聯網連接如果沒有我想知道是否有替代方法。
我的應用程序具有打開藍牙的作用,我是否關閉了它,然后如果設備藍牙 state 已連接或未連接到另一台設備。
void checkconnectivity() async{
//check bluetooth connectivity
}
你可以用這個package藍牙
例子:
/// Create a connection to the device
var deviceConnection = flutterBlue.connect(device).listen((s) {
if(s == BluetoothDeviceState.connected) {
// device is connected, do something
}
});
/// Disconnect from device
deviceConnection.cancel();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.