Skip to content
New issue

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

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

Already on GitHub? # 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
Contributor

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
Contributor

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); 
});

# for free to join this conversation on GitHub. Already have an account? # 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