Line data Source code
1 : /// [DetailsRepository] allows to retrieve an item based on its id. 2 : /// 3 : /// [T] - the element type. 4 : /// [I] - the element's id type. 5 : abstract class DetailsRepository<T, I> { 6 : /// Retrieves an element with given id. When there's no element matching the 7 : /// given [id] null should be returned or [ElementNotFoundException] should 8 : /// be thrown. 9 : Future<T> getById(I id); 10 : } 11 : 12 : /// Exception indicating that element with [id] was not found in the 13 : /// repository. 14 : class ElementNotFoundException<I> implements Exception { 15 : final I id; 16 : 17 1 : ElementNotFoundException(this.id); 18 : 19 0 : @override 20 : String toString() => 21 0 : 'ElementNotFoundException: Unable to find element with id $id.'; 22 : }