Skip to content

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

Description

@OrhanCanKocaoz

Priority/Impact

High (critical issue, blocks workflow)

Description

Describe the bug

When starting a workout in gym mode, the app crashes immediately with LateInitializationError: Field 'exercise' has not been initialized. The routine and its exercises display correctly everywhere else in the app and on the web frontend — the crash only happens when entering gym mode to actually perform the workout.

Server-side data has been verified as valid: the routine, day, slot and slotentry are all correctly linked to an existing exercise, with no empty slots and no dangling exercise references. The crash appears to be client-side during gym mode initialisation, not a data problem.

To Reproduce

  1. Create a routine with at least one day containing one exercise (via web frontend or app)
  2. Let it sync to the app via PowerSync
  3. Open the routine and start the workout (gym mode)
  4. App crashes with the error below

Expected behavior

Gym mode opens and lets me perform the workout.

Logs

LateInitializationError: Field 'exercise' has not been initialized.
#0 StartPage.build. (package:wger/features/routines/widgets/gym_mode/start_page.dart)
#1 Iterable.fold (dart:core/iterable.dart:427)
#2 StartPage.build (package:wger/features/routines/widgets/gym_mode/start_page.dart:253)
#3 _ConsumerState.build (package:flutter_riverpod/src/core/consumer.dart:283)

Relevant app log lines around the crash:

[GymStateNotifier] Initialized 8 pages
[GymStateNotifier] Day ID mismatch or expired validUntil date. Resetting to page 0.
[main] Error caught by FlutterError.onError: LateInitializationError: Field 'exercise' has not been initialized.

Additional context

Data verified directly in the database — the slotentry links to a valid existing exercise (manager_slotentryexercises_exercise join returns no NULL exercise references, and there are no empty slots without a slotentry). So this looks like a client-side initialisation issue in gym mode's StartPage, triggered even with valid routine data.

Server version

Setup - App version: 2.0.3 / build 250 (Android) - Server version: self-hosted wger 2.7.0-alpha1 - Sync: PowerSync (self-hosted, official docker stack)

Mobile app version

2.1.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions