flutter_workoutkit 1.0.0
flutter_workoutkit: ^1.0.0 copied to clipboard
Create, preview, validate and schedule custom workouts for the Apple Watch Workout app using Apple's WorkoutKit.
Changelog #
1.0.0 #
First stable release. The public API now follows semantic versioning: breaking changes only in a new major version. Upgrading from 0.0.x? See the README's "Migrating from 0.0.x to 1.0.0" section.
Breaking #
- The minimum iOS version is now 17.0 in the podspec. Apps targeting older versions previously crashed with an unregistered platform view.
WorkoutAlertis abstract, andWorkoutAlert.fromJsonreturns the concrete alert subclass.IntervalBlock.typeis optional and deprecated. WorkoutKit never used it.- Removed
WorkoutService. It called a native method that didn't exist. toJson()omits null fields.WorkoutPreviewButtonno longer shows the Apple logo. UsesfSymbolto add an icon.PaceRangeAlert/PaceThresholdAlerthave a new API. They were not exported before.sampleSingleGoalEnergyWorkoutnow uses 500 kcal instead of 1000 small calories.- Requires Flutter 3.27+. Tested with Flutter 3.47.7 (Dart 3.13).
- iOS sources moved from
ios/Classestoios/flutter_workoutkit/Sources/flutter_workoutkitfor Swift Package Manager support. - Dart sources moved to snake_case files and directories (
workout_alerts/,workout_parts/, no.class.dart/.enum.dartsuffixes). Only affects imports ofsrc/files; the public import is unchanged. WorkoutActivityType.danceis deprecated (Apple deprecatedHKWorkoutActivityType.dancein iOS 14) and is sent ascardioDance.
Added #
WorkoutKit.presentPreview(workout)opens Apple's preview sheet from any Flutter UI and completes when it closes.WorkoutPreviewButtonis unchanged.- Structured validation issues:
WorkoutValidationResult.detailsandWorkoutkitException.validationIssuesgive each problem aWorkoutValidationIssueCodeand a path such asblocks[0].steps[1]. ==,hashCodeandcopyWithon all workouts, steps, goals, intervals, alerts and scheduled workouts.- WorkoutKit's
StateErroris reported asWATCH_NOT_PAIRED/WORKOUT_APP_NOT_INSTALLED(WorkoutkitErrorCode). WorkoutKitas the entry point name.Workoutkitkeeps working as an alias.- Swift Package Manager support, which Flutter now uses by default. CocoaPods is still supported.
WorkoutActivityType.cardioDanceandsocialDance.WorkoutScheduler:isSupported,authorizationState,requestAuthorization,schedule,scheduledWorkouts,remove,markComplete,removeAll,maxAllowedScheduledWorkoutCount, plus theScheduledWorkoutmodel.Workoutkit.validate, which runs WorkoutKit'ssupportsActivity,supportsGoal,supportsAlertandsupportsActivityOrderingchecks.Workoutkit.exportWorkout/importWorkout, using WorkoutKit'sdataRepresentation.- The
poolSwimDistanceWithTimegoal (iOS 18). - Pace alerts (
PaceRangeAlert,PaceThresholdAlert) with aPaceUnit(per km or per mile). - Named
WorkoutGoalconstructors:.open(),.distance(),.time(),.energy()and.poolSwimDistanceWithTime(). Workout.fromJson, which returns the right subclass, and an optionalWorkout.id.WorkoutkitExceptionandWorkoutkitErrorCodefor native errors.WorkoutPreviewButton.sfSymbolandWorkoutPreviewButton.onError.- New samples:
sampleTempoPaceRunandsamplePoolSwimIntervals. - Tests:
- Shared JSON contract fixtures checked by both Dart and Swift tests, plus method channel and widget tests, Swift XCTests, integration tests, and GitHub Actions CI.
- Regression suites: 0.0.11 source and JSON compatibility, sample goldens, a 300-workout seeded random corpus that must never crash WorkoutKit, simulated iOS 17.0 fallbacks, and a fake scheduler.
Fixed #
- The app crashed when WorkoutKit was given an unsupported workout (WorkoutKit traps). Workouts are now checked before they are built, and failures come back as
UNSUPPORTED_WORKOUT. - The app crashed on any malformed or incomplete workout JSON (force unwraps and
fatalError). These now throwINVALID_ARGUMENT. CadenceRangeAlertdidn't send its bounds, which crashed the native side.fromJsonround-trips were broken:WorkoutAlertType.fromStringandUnitSpeed.fromStringnever matched.- Lists were decoded as
List<dynamic>. - Alerts lost their subclass and values.
- Integer JSON numbers failed
as doublecasts.
- Time goals and pacer durations were truncated by integer division, so 90 s shown in minutes became 1 minute.
- Unknown alert types silently became heart rate zone 1.
- The preview button leaked a hosting view controller into the root view controller for every button.
- The preview button didn't update when its workout or style changed.
- Speed alert metrics no longer require iOS 17.4.
dart:iois no longer imported, so the package compiles for web.Color.valuedeprecation warnings.pod lib lintwarnings: missing license type and missing source.- Native code compiles without warnings under complete strict-concurrency checking (Swift 6 readiness).
Deprecated #
Workoutkit.requestHealthPermissions/hasHealthPermissions. WorkoutKit doesn't need HealthKit permissions.
0.0.11 #
- BREAKING: Changed main import from
workoutkit.darttoflutter_workoutkit.dart - Added display string methods to all workout alert classes and enums
0.0.10 #
- Added
toJsonandfromJsonmethods to all workout classes - Added
iconDataproperty toWorkoutActivityTypeenum
0.0.9 #
- Added
hasHealthPermissionsmethod to the Workoutkit class
0.0.8 #
- Minor fixes
0.0.7 #
0.0.6 #
- Added basic customization options for
WorkoutPreviewButtonwidget
0.0.5 #
0.0.4 #
- Minor fixes
0.0.3 #
- Minor fixes
0.0.2 #
- Minor fixes
0.0.1 #
- Initial release of the Flutter WorkoutKit plugin.