angel_paginate 2.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 83

paginate #

Pub build status

Platform-agnostic pagination library, with custom support for the Angel framework.

Installation #

In your pubspec.yaml file:

dependencies:
  angel_paginate: ^2.0.0

Usage #

This library exports a Paginator<T>, which can be used to efficiently produce instances of PaginationResult<T>. Pagination results, when serialized to JSON, look like this:

{
  "total" : 75,
  "items_per_page" : 10,
  "previous_page" : 3,
  "current_page" : 4,
  "next_page" : 5,
  "start_index" : 30,
  "end_index" : 39,
  "data" : ["<items...>"]
}

Results can be parsed from Maps using the PaginationResult<T>.fromMap constructor, and serialized via their toJson() method.

To create a paginator:

import 'package:angel_paginate/angel_paginate.dart';

main() {
  var p = new Paginator(iterable);
  
  // Get the current page (default: page 1)
  var page = p.current;
  print(page.total);
  print(page.startIndex);
  print(page.data); // The actual items on this page.
  p.next(); // Advance a page
  p.back(); // Back one page
  p.goToPage(10); // Go to page number (1-based, not a 0-based index)
}

The entire Paginator API is documented, so check out the DartDocs.

Paginators by default cache paginations, to improve performance as you shift through pages. This can be especially helpful in a client-side application where your UX involves a fast response time, i.e. a search page.

2.0.0 #

  • Dart2 + Angel2 update.

example/main.dart

import 'package:angel_paginate/angel_paginate.dart';

main() {
  var iterable = [1, 2, 3, 4];
  var p = new Paginator(iterable);

  // Get the current page (default: page 1)
  var page = p.current;
  print(page.total);
  print(page.startIndex);
  print(page.data); // The actual items on this page.
  p.next(); // Advance a page
  p.back(); // Back one page
  p.goToPage(10); // Go to page number (1-based, not a 0-based index)
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  angel_paginate: ^2.0.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:angel_paginate/angel_paginate.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
67
Health:
Code health derived from static analysis. [more]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
83
Learn more about scoring.

We analyzed this package on Oct 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:angel_paginate/angel_paginate.dart.

Health suggestions

Fix lib/angel_paginate.dart. (-2.96 points)

Analysis of lib/angel_paginate.dart reported 6 hints, including:

line 18 col 44: Use = to separate a named parameter from its default value.

line 18 col 62: Use = to separate a named parameter from its default value.

line 42 col 7: DO use curly braces for all flow control structures.

line 44 col 7: DO use curly braces for all flow control structures.

line 67 col 7: DO use curly braces for all flow control structures.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
angel_framework ^2.0.0-alpha 2.0.4+1 2.0.5-beta
Transitive dependencies
angel_container 1.1.0
angel_http_exception 1.1.0
angel_model 1.0.3
angel_route 3.0.6
charcode 1.1.2
code_buffer 1.0.1
collection 1.14.12
combinator 1.1.0
convert 2.1.1
crypto 2.1.3
dart2_constant 1.0.2+dart2
file 5.1.0
http2 1.0.0
http_parser 3.1.3
http_server 0.9.8+3
intl 0.16.0
matcher 0.12.5
merge_map 1.0.2
meta 1.1.7
mime 0.9.6+3
mock_request 1.0.6
path 1.6.4
pedantic 1.8.0+1
quiver 2.0.5
quiver_hashcode 2.0.0
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
tuple 1.0.3
typed_data 1.1.6
uuid 2.0.2
Dev dependencies
angel_test ^2.0.0
logging ^0.11.0 0.11.3+2
test ^1.0.0