PageBloc constructor

PageBloc(
  1. int max,
  2. int min
)

Implementation

PageBloc(this.max, this.min) : super(PageInitial()) {
  on<NextEvent>((event, emit) {
    index++;
    if (index < max) {
      emit(Moving(index));
    } else {
      index = max;
      emit(NoChange());
    }
  });
  on<PreviousEvent>((event, emit) {
    index--;
    if (index > min) {
      emit(Moving(index));
    } else {
      index = min;
      emit(NoChange());
    }
  });
  on<MoveEvent>((event, emit) {
    index = event.index;
    emit(Moving(index));
  });
}