database: Tolerate null as page value

This commit is contained in:
Elias Projahn 2020-05-01 14:53:16 +02:00
parent 2729ed31d1
commit f81c3ed940

View file

@ -36,10 +36,8 @@ class Database extends _$Database {
/// This will return a list of [pageSize] persons. You can get another page /// This will return a list of [pageSize] persons. You can get another page
/// using the [page] parameter. If a non empty [search] string is provided, /// using the [page] parameter. If a non empty [search] string is provided,
/// the persons will get filtered based on that string. /// the persons will get filtered based on that string.
Future<List<Person>> getPersons([int page = 0, String search]) async { Future<List<Person>> getPersons([int page, String search]) async {
assert(page != null); final offset = page != null ? page * pageSize : 0;
final offset = page * pageSize;
List<Person> result; List<Person> result;
if (search == null || search.isEmpty) { if (search == null || search.isEmpty) {
@ -66,10 +64,8 @@ class Database extends _$Database {
/// This will return a list of [pageSize] instruments. You can get another /// This will return a list of [pageSize] instruments. You can get another
/// page using the [page] parameter. If a non empty [search] string is /// page using the [page] parameter. If a non empty [search] string is
/// provided, the instruments will get filtered based on that string. /// provided, the instruments will get filtered based on that string.
Future<List<Instrument>> getInstruments([int page = 0, String search]) async { Future<List<Instrument>> getInstruments([int page, String search]) async {
assert(page != null); final offset = page != null ? page * pageSize : 0;
final offset = page * pageSize;
List<Instrument> result; List<Instrument> result;
if (search == null || search.isEmpty) { if (search == null || search.isEmpty) {
@ -129,10 +125,8 @@ class Database extends _$Database {
/// using the [page] parameter. If a non empty [search] string is provided, /// using the [page] parameter. If a non empty [search] string is provided,
/// the works will be filtered using that string. /// the works will be filtered using that string.
Future<List<WorkInfo>> getWorks(int personId, Future<List<WorkInfo>> getWorks(int personId,
[int page = 0, String search]) async { [int page, String search]) async {
assert(page != null); final offset = page != null ? page * pageSize : 0;
final offset = page * pageSize;
List<Work> works; List<Work> works;
if (search == null || search.isEmpty) { if (search == null || search.isEmpty) {
@ -205,10 +199,8 @@ class Database extends _$Database {
/// This will return a list of [pageSize] ensembles. You can get another page /// This will return a list of [pageSize] ensembles. You can get another page
/// using the [page] parameter. If a non empty [search] string is provided, /// using the [page] parameter. If a non empty [search] string is provided,
/// the ensembles will get filtered based on that string. /// the ensembles will get filtered based on that string.
Future<List<Ensemble>> getEnsembles([int page = 0, String search]) async { Future<List<Ensemble>> getEnsembles([int page, String search]) async {
assert(page != null); final offset = page != null ? page * pageSize : 0;
final offset = page * pageSize;
List<Ensemble> result; List<Ensemble> result;
if (search == null || search.isEmpty) { if (search == null || search.isEmpty) {
@ -308,10 +300,8 @@ class Database extends _$Database {
/// ///
/// This will return a list of [pageSize] recordings. You can get the other /// This will return a list of [pageSize] recordings. You can get the other
/// pages using the [page] parameter. /// pages using the [page] parameter.
Future<List<RecordingInfo>> getRecordings(int workId, [int page = 0]) async { Future<List<RecordingInfo>> getRecordings(int workId, [int page]) async {
assert(page != null); final offset = page != null ? page * pageSize : 0;
final offset = page * pageSize;
final recordings = await recordingsByWork(workId, pageSize, offset).get(); final recordings = await recordingsByWork(workId, pageSize, offset).get();
final List<RecordingInfo> result = []; final List<RecordingInfo> result = [];