A simple Flutter plugin for turning on and off Bluetooth on Android devices.
Since turnOnBluetooth and turnOffBluetooth both return a
Future<bool> you can await them. So as shown in theexample you can use the bool for checking if the invocation was successful.
bool success = false; success = await BluetoothOnOff.turnOnBluetooth;
Because Bluetooth emulation is not supported by AVD you need to run your Flutter project on a physical device.
Currently only Android is supported.
Check the console. If the plugin fails to turn on or off Bluetooth it will print a string containing any of the following self explanatory PlatformExceptions:
Demonstrates how to use the BluetoothOnOff plugin.
Check theexample on GitHub
Add this to your package's pubspec.yaml file:
dependencies: bluetoothonoff: ^0.1.0
You can install packages from the command line:
$ flutter packages get
Alternatively, your editor might support
flutter packages get.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
|0.1.0||Apr 4, 2019|
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
We analyzed this package on Apr 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.
Document public APIs. (-1 points)
5 out of 5 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.