Line data Source code
1 : import 'package:equatable/equatable.dart'; 2 : import 'package:flutter/foundation.dart'; 3 : 4 : /// List of elements with information whether there could be even more elements. 5 : /// 6 : /// [T] - type of list elements. 7 : @immutable 8 : class PagedList<T> extends Equatable { 9 : final List<T> elements; 10 : final bool hasReachedMax; 11 : 12 : /// Creates paged list. 13 : /// 14 : /// [elements] - list of elements, cannot be null or empty, 15 : /// [hasReachedMax] - flag informing if all elements has already been fetched. 16 : /// True if there are more pages, false otherwise. 17 1 : PagedList(this.elements, {this.hasReachedMax = false}) 18 : : assert( 19 1 : elements != null && elements.isNotEmpty, 20 : 'Elements cannot be empty', 21 : ); 22 : 23 0 : bool get hasMoreElements => !hasReachedMax; 24 : 25 1 : @override 26 3 : List<Object> get props => [elements, hasReachedMax]; 27 : 28 1 : @override 29 3 : String toString() => '$elements, hasReachedMax: $hasReachedMax'; 30 : }