Skip to content

fix(gym_mode): prevent LateInitializationError during exercise hydration (#1366) - #1370

Open
pankaj-basnet wants to merge 1 commit into
wger-project:masterfrom
pankaj-basnet:fix-bug-gym-mode
Open

pankaj-basnet wants to merge 1 commit into
wger-project:masterfrom
pankaj-basnet:fix-bug-gym-mode

Conversation

@pankaj-basnet

Copy link
Copy Markdown
Contributor

Summary

Fixes a LateInitializationError crash occurring in gym-mode pages when accessing SetConfigData.exercise before local exercise reference data has finished syncing via PowerSync (#1366).

This PR makes SetConfigData safely nullable (matching the existing SlotEntry hydration pattern), guards the UI against unhydrated exercises, and skips incomplete pages in GymStateNotifier until hydration completes.

Root Cause

SetConfigData declared late Exercise exercise with no initializer, relying on RoutinesNotifier._hydrateRoutine() to attach Exercise instances asynchronously post-sync. When GymStateNotifier.calculatePages() ran before the exercises table finished syncing, gym-mode widgets (StartPage, ExerciseOverview, LogPage) attempted to read .exercise on unhydrated objects, throwing a LateInitializationError.

File Changes & ]

Proposed Changes

Related Issue(s)

Fixes #1366

Please check that the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Set a 100-character limit to avoid white space diffs (run dart format .)

…ion (wger-project#1366)

- Replace unguarded  in SetConfigData with safe  getter/setter and .
- Update , , and  to guard against un-hydrated exercise references.
- Skip un-hydrated sets in  to avoid building invalid gym mode pages during initial PowerSync sync.

Fixes wger-project#1366
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gym mode crashes with LateInitializationError: Field 'exercise' has not been initialized when starting a workout

1 participant