refactor(meditate): the player's buttons read their cubit as they are pressed

leancode_lint's avoid_context_read_in_build, which only the root's analysis
runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-11-03 16:51:04 +01:00
commit abac248b76
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -57,7 +57,6 @@ class const _Listening({required final ListeningPlan plan})
final l10n = AppLocalizations.of(context);
final theme = Theme.of(context);
final state = context.watch<ListeningCubit>().state;
final cubit = context.read<ListeningCubit>();
final length = plan.length;
final position = state.position > length ? length : state.position;
return TopGradient(
@ -126,7 +125,9 @@ class const _Listening({required final ListeningPlan plan})
onChanged: state.phase == ListeningPhase.loading
? null
: (value) => unawaited(
cubit.seek(Duration(milliseconds: value.round())),
context.read<ListeningCubit>().seek(
Duration(milliseconds: value.round()),
),
),
),
Row(
@ -143,13 +144,15 @@ class const _Listening({required final ListeningPlan plan})
FilledButton.icon(
icon: const Icon(LucideIcons.play),
label: Text(l10n.libraryResume),
onPressed: () => unawaited(cubit.resume()),
onPressed: () =>
unawaited(context.read<ListeningCubit>().resume()),
)
else
FilledButton.tonalIcon(
icon: const Icon(LucideIcons.pause),
label: Text(l10n.libraryPause),
onPressed: () => unawaited(cubit.pause()),
onPressed: () =>
unawaited(context.read<ListeningCubit>().pause()),
),
],
},