Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I check Bluetooth On/Off State? #30

Closed
JAICHANGPARK opened this issue May 28, 2019 · 3 comments
Closed

How can I check Bluetooth On/Off State? #30

JAICHANGPARK opened this issue May 28, 2019 · 3 comments
Assignees
Labels
Type: Enhancement New feature or request. Type: Question Further information is requested.

Comments

@JAICHANGPARK
Copy link

I'd like to check Bluetooth On/Off State before connection

Can I check this?

@FWeissenb
Copy link
Contributor

There is an "isOn"

Should be something like (untested)

var isOn = await FlutterBluetoothSerial.instance.isOn;

if(isOn) {
//TODO
}

@AgainPsychoX
Copy link
Collaborator

In few days there might be: See #35

@AgainPsychoX AgainPsychoX self-assigned this Jun 18, 2019
@AgainPsychoX AgainPsychoX added Type: Enhancement New feature or request. Type: Question Further information is requested. labels Jun 18, 2019
@AgainPsychoX
Copy link
Collaborator

The pull request #35 will be merged soon, and it adds the option, so the issue is being closed.
And there is syntax:

// Single call check
bool isEnabled = await FlutterBluetoothSerial.instance.isEnabled;

// Or listening for changes
FlutterBluetoothSerial.instance.onStateChanged().listen((BluetoothState state) {
    // The `BluetoothState` has enum-like interface with `isEnabled` getter (true if `state == BluetoothState.STATE_ON` 
    print(state.isEnabled); 
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement New feature or request. Type: Question Further information is requested.
Projects
None yet
Development

No branches or pull requests

3 participants