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