パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v1.0.1

fitness

歩数データを読み取るためのFlutterプラグイン。iOSではHealthKit、AndroidではGoogleFitをラップしています。

AndroidiOS
30日間ダウンロード
50
いいね数
29
Pub ポイント
140

パッケージをインストール

flutter pub add fitness

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

フィットネスパッケージは、ネイティブなヘルスプラットフォームから歩数データにアクセスできるFlutterプラグインです。iOSではHealthKitと統合され、AndroidではGoogle Fitに接続されます。これにより、開発者はクロスプラットフォームで歩数情報を取得でき、フィットネスやウェルネスアプリへの健康データの統合を簡素化できます。プラグインは、プラットフォーム固有の設定と権限を自動的に処理し、デバイス間で一貫したAPIを提供します。

用途

  • 毎日の歩数を追跡する
  • フィットネスダッシュボードの構築
  • ヘルスアナリティクスとの統合
  • ユーザー活動目標の有効化
  • ウェルネスアプリのサポート

主な機能

  • クロスプラットフォームでの歩数アクセス
  • HealthKit (iOS) 統合
  • Google Fit(Android)の統合
  • 自動権限処理
  • 歩数データ取得のためのシンプルなAPI

適している対象

  • フィットネスアプリ開発者
  • ウェルネスアプリケーション作成者
  • ヘルスデータ統合者
  • iOS および Android の両方をターゲットにするモバイル開発者

注意事項

  • 両方のプラットフォームでユーザーの許可が必要です
  • iOS および Android マニフェストでの適切な構成が必要です
  • 歩数に限定(その他の健康指標は除く)
  • ユーザーがHealthKitまたはGoogle Fitを有効にしているかどうかに依存します
  • 継続的なトラッキングにはバックグラウンド実行の設定が必要になる場合があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Fitness

pub package

Flutter plugin for reading step count data. Wraps HealthKit on iOS and GoogleFit on Android.

Related Document

:point_right: Korean

Getting Started

Check out the example directory for a sample app.

Add pubspec.yaml

To use this plugin, add fitness as a dependency in your pubspec.yaml file.

Android Integration

Enable Fitness API and obtain an OAuth 2.0 client ID.

iOS Integration

Enable HealthKit and add NSHealthShareUsageDescription key to the Info.plist file.

Usage

Fitness.hasPermission

Check if the user has previously granted the necessary data access.

Note: Quite rightly so, Apple deems even the information as to whether a user accepted or denied the read permission for HealthKit as sensitive information. For this reason, HealthKit does not have a clear way to check permissions.

As a workaround, it checks whether you can read data within the last month or not to see if you actually have read access.

void _hasPermission() async {
  final result = await Fitness.hasPermission();
}
Fitness.requestPermission

Initiate the authorization flow.

  • Android: Request OAuth permission and request permission to read step count history from Google Fit. It also creates a subscription to synchronize step count data.

  • iOS: Request permission to read step count history from Health Kit. Since it returns whether the request for HKHealthStore.requestAuthorization was successful or not, it is recommended to use Fitness.hasPermission in the case of iOS to check if there is permission again.

void _requestPermission() async {
  final result = await Fitness.requestPermission();
}
Fitness.revokePermission
  • Android: All OAuth permissions granted to Googlt Fit are revoked and all subscriptions created in the app are removed.

  • iOS: Feature is not supported, so it always returns true.

void _revokePermission() async {
  final result = await Fitness.revokePermission();
}
Fitness.read

Requests user's step data with Google Fit or Health Kit.

When requested without any arguments, the daily step count is requested by default.

Parameters
  • timeRange
    • defaults: from 00:00:00 to 23:59:59
    • type: TimeRange [class]
  • bucketByTime
    • defaults: 1
    • type: int
  • timeUnit
    • defaults: TimeUnit.day
    • type: TimeUnit [enum]
// Request data for the last 7 days.
void _read() async {
  final now = DateTime.now();
  final results = await Fitness.read(
    timeRange: TimeRange(
      start: now.subtract(const Duration(days: 7)),
      end: now,
    ),
    bucketByTime: 1,
    timeUnit: TimeUnit.days,
  );
}

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。