beacon_util 0.0.1
beacon_util: ^0.0.1 copied to clipboard
This is a Flutter plugin project for iOS that handles Bluetooth beacon scanning and management.
Beacon Utility Flutter Plugin #
A Flutter plugin for iOS that provides Bluetooth beacon scanning and management capabilities. This plugin allows Flutter applications to interact with nearby Bluetooth beacons and monitor their states.
Features #
- Bluetooth beacon scanning and management
- Real-time beacon data streaming
- Bluetooth permission handling
- Bluetooth state monitoring
- Support for multiple beacon properties (name, UUID, major, minor, RSSI)
Installation #
Add this to your package's pubspec.yaml file:
dependencies:
beacon_util: ^0.0.1
Usage #
Initialize the Plugin #
import 'package:beacon_util/beacon_util.dart';
Check Bluetooth Permissions #
// Check Bluetooth permissions and state
String permissionStatus = await BeaconPlugin.checkPermissions();
Possible permission status values:
bluetoothOn: Bluetooth is powered on and readybluetoothOff: Bluetooth is powered offbluetoothPermissionFailed: Bluetooth permission is deniedbluetoothUnsupported: Device doesn't support BluetoothbluetoothUnknown: Unknown Bluetooth state
Start/Stop Scanning #
// Start scanning for beacons
await BeaconPlugin.startScan();
// Stop scanning
await BeaconPlugin.stopScan();
Listen to Beacon Events #
// Listen to beacon list
BeaconPlugin.receiveBeacons().listen((beacons) {
for (var beacon in beacons) {
print('Beacon: ${beacon.name}, UUID: ${beacon.uuid}, Major: ${beacon.major}, Minor: ${beacon.minor}, RSSI: ${beacon.rssi}');
}
});
Monitor Bluetooth State #
// Listen to Bluetooth state changes
BeaconPlugin.beaconStateController.stream.listen((state) {
switch (state) {
case BeaconState.bluetoothOn:
print('Bluetooth is ON');
break;
case BeaconState.bluetoothOff:
print('Bluetooth is OFF');
break;
case BeaconState.bluetoothPermissionFailed:
print('Bluetooth permission denied');
break;
case BeaconState.bluetoothUnsupported:
print('Bluetooth is unsupported on this device');
break;
case BeaconState.bluetoothUnknown:
print('Unknown Bluetooth state');
break;
}
});
Platform Support #
Currently, this plugin only supports iOS platform.
Requirements #
- iOS 11.0 or higher
- Flutter 2.0.0 or higher
- Xcode 12.0 or higher
Dependencies #
- Flutter
- CoreBluetooth
- MinewBeaconManager
Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.