Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.law4devs.eu/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Every list() call returns a Page<T>. The iter() method returns a Stream<T> that lazily auto-paginates across all pages.

The Page<T> Object

final page = await client.frameworks.list(page: 1, perPage: 20);

page.data          // List<T> — items on this page
page.meta.total    // int — total items across all pages
page.meta.page     // int — current page number
page.meta.perPage  // int — items per page
page.meta.pages    // int — total number of pages
page.links.next    // String? — URL of next page (null if last page)
page.links.prev    // String? — URL of previous page (null if first page)
page.hasNext       // bool — true if more pages exist
PageMeta fields
FieldTypeDescription
apiVersionStringAPI version string
totalintTotal items
pageintCurrent page
perPageintItems per page
pagesintTotal pages

Manual Pagination

var page = 1;
while (true) {
  final result = await client.frameworks.list(page: page, perPage: 20);
  for (final fw in result.data) {
    print(fw.name);
  }
  if (!result.hasNext) break;
  page++;
}

Automatic Pagination with iter()

iter() returns a Stream<T> — it fetches the next page only when the current page is exhausted:
await for (final fw in client.frameworks.iter()) {
  print(fw.name);
}
With a custom page size:
await for (final a in client.articles.iter('gdpr', perPage: 50)) {
  print(a.title);
}

Early Stopping

await for (final fw in client.frameworks.iter()) {
  if (fw.slug == 'gdpr') {
    print('Found GDPR');
    break;
  }
}

Progress Tracking

var count = 0;
final total = (await client.frameworks.list()).meta.total;

await for (final fw in client.frameworks.iter()) {
  count++;
  print('[$count/$total] ${fw.name}');
}