fit_sdk library

FIT SDK for Dart

A Dart port of the Garmin FIT (Flexible and Interoperable Data Transfer) SDK. This library allows you to encode and decode FIT files used by Garmin and other fitness devices.

Features

  • Decode FIT files from Garmin devices
  • Encode new FIT files programmatically
  • Full support for FIT Protocol v2.0
  • Includes FIT Profile v21.188
  • Developer field support
  • Message broadcasting system

Usage

Decoding a FIT File

import 'dart:io';
import 'package:fit_sdk/fit_sdk.dart';

void main() async {
  final file = File('activity.fit');
  final bytes = await file.readAsBytes();

  final decoder = Decode();
  decoder.onMesg = (Mesg mesg) {
    print('Message: ${mesg.name}');
  };

  decoder.read(bytes);
}

Encoding a FIT File

import 'package:fit_sdk/fit_sdk.dart';

void main() {
  final encoder = Encode();
  encoder.open();

  final fileIdMesg = FileIdMesg();
  fileIdMesg.setType(File_.activity);

  encoder.writeMesgDefinition(fileIdMesg.getDefinition());
  encoder.writeMesg(fileIdMesg);

  final bytes = encoder.close();
}

Classes

AadAccelFeaturesMesg
AccelerometerDataMesg
AccumulatedField
Accumulator
Activity
ActivityClass
ActivityLevel
ActivityMesg
ActivitySubtype
ActivityType
AnalogWatchfaceLayout
AntChannelId
AntChannelIdMesg
AntNetwork
AntplusDeviceType
AntRxMesg
AntTxMesg
AttitudeStage
AttitudeValidity
AutoActivityDetect
AutolapTrigger
Autoscroll
AutoSyncFrequency
AviationAttitudeMesg
BacklightMode
BacklightTimeout
BandedExercisesExerciseName
BarometerDataMesg
BatteryStatus
BattleRopeExerciseName
BeatIntervalsMesg
BenchPressExerciseName
BikeExerciseName
BikeLightBeamAngleMode
BikeLightNetworkConfigType
BikeOutdoorExerciseName
BikeProfileMesg
BleDeviceType
BloodPressureMesg
BodyLocation
BpStatus
BufferedMesgBroadcaster
CadenceZoneMesg
CalfRaiseExerciseName
CameraEventMesg
CameraEventType
CameraOrientationType
CapabilitiesMesg
CardioExerciseName
CarryExerciseName
CcrSetpointSwitchMode
Checksum
ChopExerciseName
ChronoShotDataMesg
ChronoShotSessionMesg
ClimbProEvent
ClimbProMesg
CommTimeoutType
ConnectivityCapabilities
ConnectivityMesg
CoreExerciseName
CourseCapabilities
CourseMesg
CoursePoint
CoursePointMesg
Crc
CrunchExerciseName
CurlExerciseName
DateMode
DayOfWeek
DeadliftExerciseName
Decode
DeveloperDataIdMesg
DeveloperDataKey
DeveloperDataLookup
DeveloperField
DeveloperFieldDefinition
DeveloperFieldDescription
DeviceAuxBatteryInfoMesg
DeviceIndex
DeviceInfoDeviceTypeSubfield
DeviceInfoMesg
DeviceInfoProductSubfield
DeviceSettingsMesg
DigitalWatchfaceLayout
DisplayHeart
DisplayMeasure
DisplayOrientation
DisplayPosition
DisplayPower
DiveAlarmMesg
DiveAlarmType
DiveAlert
DiveApneaAlarmMesg
DiveBacklightMode
DiveGasMesg
DiveGasMode
DiveGasStatus
DiveSettingsHeartRateSourceSubfield
DiveSettingsMesg
DiveSummaryMesg
EllipticalExerciseName
Encode
EndianBinaryReader
EndianBinaryWriter
Event
EventDataSubfield
EventMesg
EventStartTimestampSubfield
EventType
ExdDataConceptConfigurationMesg
ExdDataFieldConfigurationMesg
ExdDataUnits
ExdDescriptors
ExdDisplayType
ExdLayout
ExdQualifiers
ExdScreenConfigurationMesg
ExerciseCategory
ExerciseTitleMesg
FaveroProduct
Field
FieldBase
FieldCapabilitiesMesg
FieldComponent
FieldDefinition
FieldDescriptionMesg
File
FileCapabilitiesMesg
FileCreatorMesg
FileFlags
FileIdMesg
FileIdProductSubfield
Fit
FitBaseType
FitBaseUnit
FitDateTime
FitListener
FitMessages
FitnessEquipmentState
FitType
FloorClimbExerciseName
FlyeExerciseName
GarminProduct
GasConsumptionRateType
Gender
Goal
GoalMesg
GoalRecurrence
GoalSource
GpsMetadataMesg
GyroscopeDataMesg
HipRaiseExerciseName
HipStabilityExerciseName
HipSwingExerciseName
HrMesg
HrmProfileMesg
HrType
HrvMesg
HrvStatus
HrvStatusSummaryMesg
HrvValueMesg
HrZoneCalc
HrZoneMesg
HsaAccelerometerDataMesg
HsaBodyBatteryDataMesg
HsaConfigurationDataMesg
HsaEventMesg
HsaGyroscopeDataMesg
HsaHeartRateDataMesg
HsaRespirationDataMesg
HsaSpo2DataMesg
HsaStepDataMesg
HsaStressDataMesg
HsaWristTemperatureDataMesg
HyperextensionExerciseName
IMesgBroadcastPlugin
IncomingMesgEventArgs
IndoorBikeExerciseName
IndoorRowExerciseName
Intensity
JumpMesg
LadderExerciseName
Language
LanguageBits0
LanguageBits1
LanguageBits2
LanguageBits3
LanguageBits4
LapAvgCadenceSubfield
LapMaxCadenceSubfield
LapMesg
LapTotalCyclesSubfield
LapTrigger
LateralRaiseExerciseName
LeftRightBalance
LeftRightBalance100
LegCurlExerciseName
LegRaiseExerciseName
LengthMesg
LengthType
LocalDateTime
LocalDeviceType
LungeExerciseName
MagnetometerDataMesg
Manufacturer
MaxMetCategory
MaxMetDataMesg
MaxMetHeartRateSource
MaxMetSpeedSource
MemoGlobMesg
Mesg
MesgBroadcaster
MesgBroadcastEventArgs
MesgCapabilitiesCountSubfield
MesgCapabilitiesMesg
MesgCount
MesgDefinition
MesgDefinitionEventArgs
MesgEventArgs
MesgNum
MessageIndex
MetZoneMesg
MonitoringCyclesSubfield
MonitoringHrDataMesg
MonitoringInfoMesg
MonitoringMesg
MoveExerciseName
NmeaSentenceMesg
NoFlyTimeMode
ObdiiDataMesg
OhrSettingsMesg
OlympicLiftExerciseName
OneDSensorCalibrationCalibrationFactorSubfield
OneDSensorCalibrationMesg
PadMesg
PlankExerciseName
PlyoExerciseName
PoseExerciseName
PowerPhaseType
PowerZoneMesg
Profile
ProjectileType
ProtocolValidator
PullUpExerciseName
PushUpExerciseName
PwrZoneCalc
RadarThreatLevelType
RawBbiMesg
RecordMesg
RespirationRateMesg
RiderPositionType
RowExerciseName
RunExerciseName
RunIndoorExerciseName
SandbagExerciseName
Schedule
ScheduleMesg
ScheduleProductSubfield
SdmProfileMesg
SegmentDeleteStatus
SegmentFileMesg
SegmentIdMesg
SegmentLapMesg
SegmentLapStatus
SegmentLapTotalCyclesSubfield
SegmentLeaderboardEntryMesg
SegmentLeaderboardType
SegmentPointMesg
SegmentSelectionType
SensorType
SessionAvgCadenceSubfield
SessionMaxCadenceSubfield
SessionMesg
SessionTotalCyclesSubfield
SessionTrigger
SetMesg
SetType
ShoulderPressExerciseName
ShoulderStabilityExerciseName
ShrugExerciseName
Side
SitUpExerciseName
SkinTempOvernightMesg
SlaveDeviceMesg
SlaveDeviceProductSubfield
SledExerciseName
SledgeHammerExerciseName
SleepAssessmentMesg
SleepDisruptionOvernightSeverityMesg
SleepDisruptionSeverity
SleepDisruptionSeverityPeriodMesg
SleepLevel
SleepLevelMesg
SoftwareMesg
SourceType
SpeedZoneMesg
SplitMesg
SplitSummaryMesg
SplitType
Spo2DataMesg
Spo2MeasurementType
Sport
SportBits0
SportBits1
SportBits2
SportBits3
SportBits4
SportBits5
SportBits6
SportEvent
SportMesg
SquatExerciseName
StairStepperExerciseName
StressLevelMesg
StrokeType
Subfield
SubfieldMap
SubSport
SupportedExdScreenLayouts
SuspensionExerciseName
SwimStroke
Switch
TankSummaryMesg
TankUpdateMesg
TapSensitivity
ThreeDSensorCalibrationCalibrationFactorSubfield
ThreeDSensorCalibrationMesg
TimeInZoneMesg
TimeMode
TimerTrigger
TimestampCorrelationMesg
TimeZone
TireExerciseName
TissueModelType
Tone
TotalBodyExerciseName
TotalsMesg
TrainingFileMesg
TrainingFileProductSubfield
TrainingSettingsMesg
TricepsExtensionExerciseName
TurnType
UserLocalId
UserProfileMesg
V1Validator
Validator
VideoClipMesg
VideoDescriptionMesg
VideoFrameMesg
VideoMesg
VideoTitleMesg
WarmUpExerciseName
WatchfaceMode
WatchfaceSettingsLayoutSubfield
WatchfaceSettingsMesg
WaterType
WeatherAlertMesg
WeatherConditionsMesg
WeatherReport
WeatherSevereType
WeatherSeverity
WeatherStatus
Weight
WeightScaleMesg
WktStepDuration
WktStepTarget
WorkoutCapabilities
WorkoutEquipment
WorkoutHr
WorkoutMesg
WorkoutPower
WorkoutSessionMesg
WorkoutStepCustomTargetValueHighSubfield
WorkoutStepCustomTargetValueLowSubfield
WorkoutStepDurationValueSubfield
WorkoutStepMesg
WorkoutStepSecondaryCustomTargetValueHighSubfield
WorkoutStepSecondaryCustomTargetValueLowSubfield
WorkoutStepSecondaryTargetValueSubfield
WorkoutStepTargetValueSubfield
ZonesTargetMesg

Exceptions / Errors

FitException