Line data Source code
1 : import 'package:flutter_bloc_patterns/src/list/paged/page.dart'; 2 : 3 : /// [PagedRepository] allows to retrieve elements using the pagination. 4 : /// 5 : /// [T] - the type of returned elements. 6 : abstract class PagedRepository<T> { 7 : /// Retrieves elements meeting the pagination restriction provided by 8 : /// the [page] object. 9 : /// When elements are exceeded should return an empty list or throw 10 : /// the [PageNotFoundException]. 11 : Future<List<T>> getAll(Page page); 12 : } 13 : 14 : // Exception thrown when page with given number doesn't exist. 15 : class PageNotFoundException implements Exception { 16 : final pageNumber; 17 : 18 1 : PageNotFoundException(this.pageNumber); 19 : 20 0 : @override 21 : String toString() => 22 0 : 'PageNotFoundException: $pageNumber page does not exist.'; 23 : }