Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Flutter plugin for reading health and fitness data. Wraps HealthKit on iOS and GoogleFit on Android.

License

NotificationsYou must be signed in to change notification settings

Touchwonders/Fitness

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pub package

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

Related Document

👉Korean

Getting Started

Check out the example directory for a sample app.

Add pubspec.yaml

To use this plugin, addfitness as adependency 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=awaitFitness.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 forHKHealthStore.requestAuthorization was successful or not, it is recommended to useFitness.hasPermission in the case of iOS to check if there is permission again.

void_requestPermission()async {final result=awaitFitness.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=awaitFitness.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=awaitFitness.read(    timeRange:TimeRange(      start: now.subtract(constDuration(days:7)),      end: now,    ),    bucketByTime:1,    timeUnit:TimeUnit.days,  );}

About

Flutter plugin for reading health and fitness data. Wraps HealthKit on iOS and GoogleFit on Android.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin36.8%
  • Swift28.1%
  • Dart28.0%
  • Ruby5.5%
  • Objective-C1.6%

[8]ページ先頭

©2009-2025 Movatter.jp