ExerciseTimeCubit class

Os minutos de treino guardados no aparelho (BL18, antes ExerciseTimeLog, um ChangeNotifier). Cada entrada entra aqui antes de qualquer rede: o treino não espera o Firestore, e o que não foi enviado continua no aparelho até o próximo envio (ExerciseTimeRecorder.sync).

Tudo fica num JSON só, em shared_preferences (a mesma gaveta do progresso dos cursos e da leitura). Se a leitura inicial falhar, o registro não grava por cima do que está guardado: ele só deixa de salvar até o próximo aparelho ler direito.

A mudança sai no estado antes da gravação. Quem ouve o stream é avisado depois, num evento assíncrono, então uma tela nunca é redesenhada no meio da mudança.

Inheritance
Implemented types

Constructors

ExerciseTimeCubit({SharedPreferencesAsync? prefs, required AppClock clock, Random? random})

Properties

clock → AppClock
O relógio do app (CT05d): a hora de cada entrada e da saída.
final
hashCode → int
The hash code for this object.
no setterinherited
isClosed → bool
Whether the bloc is closed.
no setterinherited
leituraOk → Future<bool>
Completa quando o que estava guardado foi lido, com true se a leitura deu certo. Com false, o registro não grava (ver _load).
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
state → ExerciseTimeState
The current state.
no setterinherited
stream → Stream<ExerciseTimeState>
The current stream of states.
no setterinherited

Methods

addError(Object error, [StackTrace? stackTrace]) → void
Reports an error which triggers onError with an optional StackTrace.
inherited
claim(TrainingSession sessao, String uid) → void
A entrada aberta sem conta passa a ser do uid que acabou de conectar.
close() → Future<void>
Closes the instance. This method should be called when the instance is no longer needed. Once close is called, the instance can no longer be used.
inherited
confirm(TrainingSession sessao, int revisao) → void
O envio da revisão revisao deu certo. A entrada só deixa de estar pendente se ninguém mudou desde então; se mudou, o próximo envio leva o total novo.
emit(ExerciseTimeState state) → void
Updates the state to the provided state. emit does nothing if the state being emitted is equal to the current state.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onChange(Change<ExerciseTimeState> change) → void
Called whenever a change occurs with the given change. A change occurs when a new state is emitted. onChange is called before the state of the cubit is updated. onChange is a great spot to add logging/analytics for a specific cubit.
inherited
onError(Object error, StackTrace stackTrace) → void
Called whenever an error occurs and notifies BlocObserver.onError.
inherited
open({required String? uid, required String treino, required String exercicio, required String plataforma}) → TrainingSession
Abre uma entrada agora. Não espera nada: a entrada já vale no estado.
toString() → String
A string representation of this object.
inherited
update(TrainingSession sessao, {required int naTela, required int tocando, bool terminou = false}) → void
Põe os totais atuais na entrada. Sem mudança, não grava nem avisa. Com terminou, marca a hora da saída (só na primeira vez).
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

chave → const String