Errors handled while the widget tree is building crashed or wedged the
app in three related ways:
- FlutterError.onError showed dialogs and snackbars synchronously.
Pushing a route mid-build trips the navigator's !_debugLocked
assertion, and because the one-dialog guard was set before showDialog
threw, its release never attached: every later error dialog was then
silently suppressed while nothing was on screen, leaving a blank,
unresponsive app until restart. Snackbars crashed outright via the
messenger's setState.
- The sync status and barcode dialogs did ref.read inside their route
builders, which run during build. With the provider chain dirty (any
token refresh dirties wgerBase -> auth), the read flushed it there and
Riverpod scheduled a scope refresh mid-build. The barcode builder also
created its search future inline, re-firing the search on every dialog
rebuild.
- Provider create bodies that widgets watch during build read providers
synchronously: the dashboard's routine hydration chain crashed on cold
start right after a token refresh, and TrophyStateNotifier.build()
has the same shape in the post-login window, where invalidation order
left networkStatusProvider dirty while its dependents rebuilt.
lib/core/build_safety.dart adds the two idioms as helpers: runAfterFrame
defers UI side effects past the build phase, yieldPastBuild yields
provider create bodies past their synchronous phase (a microtask, not a
timer, since widget tests assert !timersPending at teardown). The error
dialog guard is released when the context is gone or the push fails, the
snackbar helpers re-resolve the messenger inside the callback, the
dialog builders snapshot their providers in the tap handler, and
post-login invalidation runs leaf-first. Regression tests cover each
shape.
When dialing in the weight over the first sets of an exercise, the log
form of every following set is pre-filled with the planned values
again, so any adjustment has to be re-entered for every set.
When the new "sticky set values" setting is enabled, the values
(weight, repetitions, RiR, units) logged for a set are remembered and
the next set of the same exercise is pre-filled with them instead of
the planned ones. This intentionally only copies the values: the id,
session, slot entry and targets stay those of a fresh template, so
saving still creates a new log row for the correct slot.
The setting is disabled by default and can be toggled in the gym mode
options; it is persisted like the other gym mode settings. The
remembered values are cleared when the workout ends.
Two related fixes for navigating back during gym mode:
* Re-visiting an already logged page showed the set-config template
again and saving inserted a second, duplicate log row. The saved log
is now kept on the slot page and the form is seeded from it, so the
previously entered values are shown and saving updates the existing
row instead of duplicating it (e.g. adding a forgotten RiR).
* The rest timers kept their start time in the widget, so leaving the
page disposed it and restarted the countdown on return. The start
time now lives in the gym state and both timers derive the elapsed
or remaining time from it, so the countdown continues while the
user e.g. goes back to correct a set. Revisiting an already expired
countdown also no longer triggers the end-of-countdown alert again.
The timer pages only showed the countdown, wasting the whole rest
period: to prepare for the next set (e.g. walk over and preload the
plates) the user had to swipe forward to see what comes next, which
also restarted the timer.
The timers now show the upcoming set below the time: exercise name,
set configuration (reps, weight, etc.) and set counter. This is always
the next log page, which can be the next set of the same exercise
(e.g. when progressing weights within an exercise) or the first set
of the next exercise. After the last set of the day nothing is shown.
Not copying an exercise that isn't there keeps the crash away, but gym
mode then holds a log with no exercise, which would bite the next reader.
The past logs widget already knows the exercise from the set config, so
pass it down to setLog, which assigns it through the exercise setter so
that exerciseId stays consistent.
The notifier test worked around the old behaviour by setting exerciseObj
on every fixture, with a comment explaining that copyWith needs it. That
was the bug, written down, so it's gone.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XzxNFoPMxsFPxHD3P2Ma3w
- implement persistence for log scope and distinct settings
- refactor(logs): update pastExerciseLogsProvider to support custom scope and deduplication
- feat(ui): add log scope controls to StartPage and LogPage