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
-
- Object
- BlocBase<
ExerciseTimeState> - Cubit<
ExerciseTimeState> - ExerciseTimeCubit
- 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
truese a leitura deu certo. Comfalse, 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
errorwhich triggers onError with an optional StackTrace.inherited -
claim(
TrainingSession sessao, String uid) → void -
A entrada aberta sem conta passa a ser do
uidque 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
revisaodeu 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
stateto the providedstate. emit does nothing if thestatebeing emitted is equal to the currentstate.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onChange(
Change< ExerciseTimeState> change) → void -
Called whenever a
changeoccurs with the givenchange. Achangeoccurs when a newstateis emitted. onChange is called before thestateof thecubitis updated. onChange is a great spot to add logging/analytics for a specificcubit.inherited -
onError(
Object error, StackTrace stackTrace) → void -
Called whenever an
erroroccurs 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