beacon_broadcast 0.2.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 89

Beacon Broadcast plugin for Flutter #

Awesome Flutter Pub

A Flutter plugin for turning your device into a beacon.

Usage #

To use this plugin, add beacon_broadcast as a dependency in your pubspec.yaml file and import:

import 'package:beacon_broadcast/beacon_broadcast.dart';

Now you can create BeaconBroadcast object and start using it:

BeaconBroadcast beaconBroadcast = BeaconBroadcast();

In the simplest case, to start advertising just set UUID, major and minor id and call start():


You can also customize your beacon before starting:

    .setTransmissionPower(-59) //optional
    .setIdentifier('com.example.myDeviceRegion') //iOS-only, optional
    .setLayout('s:0-1=feaa,m:2-2=10,p:3-3:-41,i:4-21v') //Android-only, optional
    .setManufacturerId(0x001D) //Android-only, optional

You can check what's current state of your beacon:

var isAdvertising = beaconBroadcast.isAdvertising()

You can also register for changes in beacon advertising state:

beaconBroadcast.getAdvertisingStateChange().listen((isAdvertising) {
    // Now you know if beacon is advertising

Before advertising, you may want to check if your device supports transmitting as a beacon. You may do it using checkTransmissionSupported() method.

var transmissionSupportStatus = await beaconBroadcast.checkTransmissionSupported();
switch (transmissionSupportStatus) {
  case BeaconStatus.SUPPORTED:
    // You're good to go, you can advertise as a beacon
  case BeaconStatus.NOT_SUPPORTED_MIN_SDK:
    // Your Android system version is too low (min. is 21)
  case BeaconStatus.NOT_SUPPORTED_BLE:
    // Your device doesn't support BLE
    // Either your chipset or driver is incompatible

If you want to stop advertising, just call stop():



Important note: For Android app, user needs to turn on Bluetooth on the device first.

Android beacon will advertise as the AltBeacon manufactured by RadiusNetwork. You can change it with setLayout() and setManufacturerId() methods.


For iOS, beacon will advertise as an iBeacon, it can't be changed. It's worth to mention that application needs to work in foreground. According to the CoreLocation documentation:


After advertising your app as a beacon, your app must continue running in the foreground to broadcast the needed Bluetooth signals. If the user quits the app, the system stops advertising the device as a peripheral over Bluetooth.

About #

This plugin uses Android Beacon Library for Android and CoreLocation for iOS.

Todo #

There are still few things left to implement:

  • [X] Adding option for checking for Android device support programmatically
  • [X] Adding option to set layout and manufacturer for Android implementation
  • [ ] Handle turning on BLE before transmitting

0.2.1 #

Updated the documentation

0.2.0 #

Added option to set manufacturer and layout for Android.

0.1.2 #

Updates in the documentation

0.1.1 #

Added method for checking if transmission is supported on the device.

0.1.0 #

First stable version of the app. No major changes

0.0.1 #

Initial version of the library. This version includes:

  • starting and stopping beacon advertising
  • setting beacon UUID, major id, minor id, transmission power and identifier


import 'dart:async';

import 'package:beacon_broadcast/beacon_broadcast.dart';
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  _MyAppState createState() => _MyAppState();

class _MyAppState extends State<MyApp> {
  static const UUID = '39ED98FF-2900-441A-802F-9C398FC199D2';
  static const MAJOR_ID = 1;
  static const MINOR_ID = 100;
  static const TRANSMISSION_POWER = -59;
  static const IDENTIFIER = 'com.example.myDeviceRegion';
  static const LAYOUT = BeaconBroadcast.ALTBEACON_LAYOUT;
  static const MANUFACTURER_ID = 0x0118;

  BeaconBroadcast beaconBroadcast = BeaconBroadcast();

  BeaconStatus _isTransmissionSupported;
  bool _isAdvertising = false;
  StreamSubscription<bool> _isAdvertisingSubscription;

  void initState() {
    beaconBroadcast.checkTransmissionSupported().then((isTransmissionSupported) {
      setState(() {
        _isTransmissionSupported = isTransmissionSupported;

    _isAdvertisingSubscription =
        beaconBroadcast.getAdvertisingStateChange().listen((isAdvertising) {
      setState(() {
        _isAdvertising = isAdvertising;

  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Beacon Broadcast'),
        body: SingleChildScrollView(
          child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text('Is transmission supported?',
                    style: Theme.of(context).textTheme.headline),
                    style: Theme.of(context).textTheme.subhead),
                Container(height: 16.0),
                Text('Is beacon started?', style: Theme.of(context).textTheme.headline),
                Text('$_isAdvertising', style: Theme.of(context).textTheme.subhead),
                Container(height: 16.0),
                  child: RaisedButton(
                    onPressed: () {
                    child: Text('START'),
                  child: RaisedButton(
                    onPressed: () {
                    child: Text('STOP'),
                Text('Beacon Data', style: Theme.of(context).textTheme.headline),
                Text('UUID: $UUID'),
                Text('Major id: $MAJOR_ID'),
                Text('Minor id: $MINOR_ID'),
                Text('Tx Power: $TRANSMISSION_POWER'),
                Text('Identifier: $IDENTIFIER'),
                Text('Layout: $LAYOUT'),
                Text('Manufacturer Id: $MANUFACTURER_ID'),

  void dispose() {
    if (_isAdvertisingSubscription != null) {

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  beacon_broadcast: ^0.2.1

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:beacon_broadcast/beacon_broadcast.dart';
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]
Learn more about scoring.

We analyzed this package on Apr 1, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Format lib/beacon_broadcast.dart.

Run flutter format to format lib/beacon_broadcast.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
test ^1.6.3