WT 1.1.26+3 bloc migration

This commit is contained in:
Tibor Bossanyi (Freelancer)
2022-04-15 08:47:32 +02:00
parent 60df0bcf2d
commit 225172f950
47 changed files with 1527 additions and 1620 deletions
+36 -24
View File
@@ -29,7 +29,42 @@ class TimerBloc extends Bloc<TimerEvent, TimerState> {
// ignore: cancel_subscriptions
StreamSubscription<int>? _tickerSubscription;
TimerBloc() : super(TimerReady(300));
TimerBloc() : super(TimerReady(300)) {
on<TimerStart>(_onStart);
on<TimerPause>(_onPause);
on<TimerResume>(_onResume);
on<TimerReset>(_onReset);
on<TimerTick>(_onTick);
on<TimerEnd>(_onEnd);
}
Stream<TimerState> _onStart(TimerStart event, Emitter<TimerState> emit) async* {
yield* _mapStartToState(event);
}
Stream<TimerState> _onPause(TimerPause event, Emitter<TimerState> emit) async* {
yield* _mapPauseToState(event);
}
Stream<TimerState> _onResume(TimerResume event, Emitter<TimerState> emit) async* {
yield* _mapResumeToState(event);
}
Stream<TimerState> _onReset(TimerReset event, Emitter<TimerState> emit) async* {
yield* _mapResetToState(event);
}
Stream<TimerState> _onTick(TimerTick event, Emitter<TimerState> emit) async* {
yield* _mapTickToState(event);
}
void _onEnd(TimerEnd event, Emitter<TimerState> emit) {
print("$event");
if (_tickerSubscription != null) {
_tickerSubscription!.cancel();
}
emit(TimerFinished(state.duration));
}
@override
void onTransition(Transition<TimerEvent, TimerState> transition) {
@@ -37,29 +72,6 @@ class TimerBloc extends Bloc<TimerEvent, TimerState> {
//print(transition);
}
@override
Stream<TimerState> mapEventToState(
TimerEvent event,
) async* {
if (event is TimerStart) {
yield* _mapStartToState(event);
} else if (event is TimerPause) {
yield* _mapPauseToState(event);
} else if (event is TimerResume) {
yield* _mapResumeToState(event);
} else if (event is TimerReset) {
yield* _mapResetToState(event);
} else if (event is TimerTick) {
yield* _mapTickToState(event);
} else if (event is TimerEnd) {
print("$event");
if (_tickerSubscription != null) {
_tickerSubscription!.cancel();
}
yield TimerFinished(state.duration);
}
}
@override
Future<void> close() {
if (_tickerSubscription != null) {