You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
955B

  1. part of 'infinity_scroll_bloc.dart';
  2. abstract class InfinityScrollState extends Equatable {
  3. const InfinityScrollState();
  4. @override
  5. List<Object> get props => [];
  6. }
  7. class InfinityScrollInitial extends InfinityScrollState {}
  8. class InfinityScrollFailure extends InfinityScrollState {
  9. final String errorString;
  10. InfinityScrollFailure({required this.errorString});
  11. }
  12. class InfinityScrollSuccess<T> extends InfinityScrollState {
  13. final List<T> items;
  14. final int page;
  15. final bool hasReachedMax;
  16. const InfinityScrollSuccess({required this.items, required this.page, required this.hasReachedMax});
  17. InfinityScrollSuccess copyWith({
  18. List<T>? items,
  19. int? page,
  20. required bool hasReachedMax,
  21. }) {
  22. return InfinityScrollSuccess(
  23. items: items ?? this.items,
  24. page: page ?? this.page,
  25. hasReachedMax: hasReachedMax ?? this.hasReachedMax,
  26. );
  27. }
  28. @override
  29. List<Object> get props => [items, hasReachedMax];
  30. }