beacon_broadcast 0.0.1 copy "beacon_broadcast: ^0.0.1" to clipboard
beacon_broadcast: ^0.0.1 copied to clipboard

outdated

A Flutter plugin for turning your device into a beacon.

example/lib/main.dart

import 'dart:async';

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

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

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

class _MyAppState extends State<MyApp> {
  BeaconBroadcast beaconBroadcast = BeaconBroadcast();

  bool _isAdvertising = false;
  StreamSubscription<bool> _isAdvertisingSubscription;

  @override
  void initState() {
    super.initState();
    _isAdvertisingSubscription =
        beaconBroadcast.getAdvertisingStateChange().listen((isAdvertising) {
      setState(() {
        _isAdvertising = isAdvertising;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              RaisedButton(
                onPressed: () {
                  beaconBroadcast
                      .setUUID('39ED98FF-2900-441A-802F-9C398FC199D2')
                      .setMajorId(1)
                      .setMinorId(100)
                      .setTransmissionPower(-59)
                      .setIdentifier("com.example.myDeviceRegion")
                      .start();
                },
                child: Text('START'),
              ),
              RaisedButton(
                onPressed: () {
                  beaconBroadcast.stop();
                },
                child: Text('STOP'),
              ),
              Text('Current state: $_isAdvertising')
            ],
          ),
        ),
      ),
    );
  }

  @override
  void dispose() {
    super.dispose();
    if (_isAdvertisingSubscription != null) {
      _isAdvertisingSubscription.cancel();
    }
  }
}
41
likes
0
pub points
87%
popularity

Publisher

unverified uploader

A Flutter plugin for turning your device into a beacon.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on beacon_broadcast