v7.10.0
polar
這是 Android 與 iOS 上 Polar SDK 的 Dart 插件包裝器
22喜歡 600近 30 天下載150Pub 分數
AndroidiOS
這是 Android 和 iOS 上 Polar SDK 的 Dart 插件包裝器
{"sdk":"flutter"}^2.0.5^13.0.1^13.0.0^4.0.0^4.9.0^1.17.0{"sdk":"flutter"}^17.0.0^2.3.2^6.5.4^4.0.0以下為英文專案原文快照,最新內容請造訪 GitHub。
Plugin wrapper for the Polar SDK
This is an unofficial wrapper for the Polar SDK. For any questions regarding the underlying SDKs or Polar devices in general, please see the official repository.
android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="30" />
If you use BLUETOOTH_SCAN to determine location, remove android:usesPermissionFlags="neverForLocation"
If you use location services in your app, remove android:maxSdkVersion="30" from the location permission tags
Change the deployment target in Xcode to iOS 14+
Podfile:
platform :ios, '14.0'
Info.plist:
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Used to connect to Polar devices</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>Used to connect to Polar devices</string>
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
</array>
import 'package:flutter/foundation.dart';
import 'package:polar/polar.dart';
const identifier = '1C709B20';
final polar = Polar();
void example() {
polar.connectToDevice(identifier);
streamWhenReady();
}
void streamWhenReady() async {
final readiness = await polar.sdkFeaturesReadiness.firstWhere(
(e) => e.identifier == identifier,
);
if (!readiness.ready.contains(PolarSdkFeature.onlineStreaming)) {
return;
}
final availabletypes = await polar.getAvailableOnlineStreamDataTypes(
identifier,
);
debugPrint('available types: $availabletypes');
if (availabletypes.contains(PolarDataType.hr)) {
polar
.startHrStreaming(identifier)
.listen((e) => debugPrint('HR data received'));
}
if (availabletypes.contains(PolarDataType.ecg)) {
polar
.startEcgStreaming(identifier)
.listen((e) => debugPrint('ECG data received'));
}
if (availabletypes.contains(PolarDataType.acc)) {
polar
.startAccStreaming(identifier)
.listen((e) => debugPrint('ACC data received'));
}
}