패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.0.1

fitness

걸음 수 데이터를 읽기 위한 Flutter 플러그인입니다. iOS에서는 HealthKit을, Android에서는 GoogleFit을 래핑합니다.

AndroidiOS
30일 다운로드
50
좋아요
29
Pub 점수
140

패키지 설치

flutter pub add fitness

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

피트니스 패키지는 네이티브 건강 플랫폼에서 걸음 수 데이터에 액세스할 수 있도록 해주는 플러터 플러그인입니다. iOS에서는 HealthKit과 통합되며, 안드로이드에서는 Google Fit과 연결됩니다. 이를 통해 개발자는 크로스플랫폼 방식으로 걸음 수 정보를 가져올 수 있어, 피트니스 또는 웰빙 애플리케이션에 건강 데이터를 쉽게 통합할 수 있습니다. 이 플러그인은 플랫폼별 설정 및 권한을 자동으로 처리하며, 장치 간 일관된 API를 제공합니다.

사용 사례

  • 일일 보행 수 추적
  • 피트니스 대시보드 구축
  • 건강 분석과의 통합
  • 사용자 활동 목표 활성화
  • 웰니스 앱 지원

주요 기능

  • 다중 플랫폼 단계 수 액세스
  • HealthKit (iOS) 통합
  • Google Fit(안드로이드) 통합
  • 자동 권한 처리
  • 단순한 API를 통한 스텝 데이터 검색

적합한 대상

  • 피트니스 앱 개발자
  • 웰니스 애플리케이션 제작자
  • 건강 데이터 통합자
  • iOS 및 안드로이드를 모두 타겟으로 하는 모바일 개발자

고려 사항

  • 두 플랫폼 모두 사용자 권한이 필요합니다
  • iOS 및 안드로이드 매니페스트에서 올바른 구성이 필요합니다
  • 걸음 수에 한정됨(기타 건강 지표 제외)
  • 사용자가 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,
  );
}

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.