flutter_beacon 0.2.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 90

flutter_beacon #

Pub GitHub

Flutter plugin to work with iBeacons.

An hybrid iBeacon scanner SDK for Flutter plugin. Supports Android API 18+ and iOS 8+.

Features:

  • Automatic permission management
  • Ranging iBeacons
  • Monitoring iBeacons

Installation #

Add to pubspec.yaml:

dependencies:
  flutter_beacon: ^0.2.2

Setup specific for Android #

Nothing.

Setup specific for iOS #

In order to use beacons related features, apps are required to ask the location permission. It's a two step process:

  1. Declare the permission the app requires in configuration files
  2. Request the permission to the user when app is running (the plugin can handle this automatically)

The needed permissions in iOS is when in use.

For more details about what you can do with each permission, see:
https://developer.apple.com/documentation/corelocation/choosing_the_authorization_level_for_location_services

Permission must be declared in ios/Runner/Info.plist:

<dict>
  <!-- When in use -->
  <key>NSLocationWhenInUseUsageDescription</key>
  <string>Reason why app needs location</string>
  <!-- Always -->
  <!-- for iOS 11 + -->
  <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
  <string>Reason why app needs location</string>
  <!-- for iOS 9/10 -->
  <key>NSLocationAlwaysUsageDescription</key>
  <string>Reason why app needs location</string>
</dict>

How-to #

Ranging APIs are designed as reactive streams.

  • The first subscription to the stream will start the ranging

Initializing Library #

try {
  await flutterBeacon.initializeScanning;
} on PlatformException {
  // library failed to initialize, check code and message
}

Ranging beacons #

final regions = <Region>[];

if (Platform.isIOS) {
  regions.add(Region(
      identifier: 'Apple Airlocate',
      proximityUUID: 'E2C56DB5-DFFB-48D2-B060-D0F5A71096E0'));
} else {
  // android platform, it can ranging out of beacon that filter all of Proximity UUID
  regions.add(Region(identifier: 'com.beacon'));
}

flutterBeacon.ranging(regions).listen((RangingResult result) {
  // result contains a region and list of beacons found
  // list can be empty if no matching beacons were found in range
});

Under the hood #

  • iOS uses native iOS CoreLocation
  • Android uses the third-party library android-beacon-library (Apache License 2.0)

Author #

Flutter Beacon plugin is developed by Alann Maulana. You can contact me at alann.maulana@outlook.com.

License #

Apache License 2.0

[0.2.2]

  • Update gradle to latest version
  • Update Android-Beacon-Library to version 2.16.1

[0.2.1]

  • Fix crash ranging when region not set for Android

[0.2.0]

  • Migrate to AndroidX

[0.1.1]

  • Fix region ranging for Android

[0.1.0]

  • Updating library docs
  • Adding example docs

[0.0.2]

  • Adding Dart Docs

[0.0.1]

  • Initial release
  • Ranging iBeacons for iOS and Android

example/README.md

Initializing Library #

try {
  await flutterBeacon.initializeScanning;
} on PlatformException {
  // library failed to initialize, check code and message
}

Ranging beacons #

final regions = <Region>[];

if (Platform.isIOS) {
  regions.add(Region(
      identifier: 'Apple Airlocate',
      proximityUUID: 'E2C56DB5-DFFB-48D2-B060-D0F5A71096E0'));
} else {
  // android platform, it can ranging out of beacon that filter all of Proximity UUID
  regions.add(Region(identifier: 'com.beacon'));
}

flutterBeacon.ranging(regions).listen((RangingResult result) {
  // result contains a region and list of beacons found
  // list can be empty if no matching beacons were found in range
});

Monitoring beacons #

final regions = <Region>[];

if (Platform.isIOS) {
  regions.add(Region(
      identifier: 'Apple Airlocate',
      proximityUUID: 'E2C56DB5-DFFB-48D2-B060-D0F5A71096E0'));
} else {
  // android platform, it can ranging out of beacon that filter all of Proximity UUID
  regions.add(Region(identifier: 'com.beacon'));
}

flutterBeacon.monitoring(regions).listen((MonitoringResult result) {
  // result contains a region, event type and event state
});

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_beacon: ^0.2.2

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:flutter_beacon/flutter_beacon.dart';
  
Version Uploaded Documentation Archive
0.2.2 May 3, 2019 Go to the documentation of flutter_beacon 0.2.2 Download flutter_beacon 0.2.2 archive
0.2.1 Apr 12, 2019 Go to the documentation of flutter_beacon 0.2.1 Download flutter_beacon 0.2.1 archive
0.2.0 Feb 5, 2019 Go to the documentation of flutter_beacon 0.2.0 Download flutter_beacon 0.2.0 archive
0.1.1 Dec 27, 2018 Go to the documentation of flutter_beacon 0.1.1 Download flutter_beacon 0.1.1 archive
0.1.0 Dec 27, 2018 Go to the documentation of flutter_beacon 0.1.0 Download flutter_beacon 0.1.0 archive
0.0.2 Dec 27, 2018 Go to the documentation of flutter_beacon 0.0.2 Download flutter_beacon 0.0.2 archive
0.0.1 Dec 27, 2018 Go to the documentation of flutter_beacon 0.0.1 Download flutter_beacon 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
81
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
95
Overall:
Weighted score of the above. [more]
90
Learn more about scoring.

We analyzed this package on Jun 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.2
  • pana: 0.12.18
  • Flutter: 1.5.4-hotfix.2

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance issues and suggestions

Support latest dependencies. (-5 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8