From e3200d87ba6d350932022b589693032cd5b97ac6 Mon Sep 17 00:00:00 2001 From: hunteraraujo Date: Sat, 2 Sep 2023 14:58:49 -0700 Subject: [PATCH] Add Pagination Model for API Responses Added a new Pagination class to model the pagination data that comes with API responses. This will help in handling paginated data more effectively and transparently. The Pagination class includes fields for total items, total pages, current page, and page size. It also includes a factory constructor for creating an instance from a JSON object. --- lib/models/pagination.dart | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 lib/models/pagination.dart diff --git a/lib/models/pagination.dart b/lib/models/pagination.dart new file mode 100644 index 00000000..cac391c9 --- /dev/null +++ b/lib/models/pagination.dart @@ -0,0 +1,22 @@ +class Pagination { + final int totalItems; + final int totalPages; + final int currentPage; + final int pageSize; + + Pagination({ + required this.totalItems, + required this.totalPages, + required this.currentPage, + required this.pageSize, + }); + + factory Pagination.fromJson(Map json) { + return Pagination( + totalItems: json['total_items'], + totalPages: json['total_pages'], + currentPage: json['current_page'], + pageSize: json['page_size'], + ); + } +}