パッケージ、リポジトリ、アプリカテゴリを検索

pager のカバー
パッケージ詳細v0.0.6

pager

数値のページネーションを構築するのに役立つウィジェットです。たとえば、カスタムページ付きテーブルを作成したい場合に便利です。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
494
いいね数
26
Pub ポイント
160

パッケージをインストール

flutter pub add pager

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Pager は、カスタム数値ページネーションインターフェースを作成するための Flutter ウィジェットで、カスタムページ付きテーブルなどのページ表示を実装するのに最適です。直感的なコントロールとさまざまなスタイルオプションをサポートし、クリーンで再利用可能な方法でページ間をナビゲートできます。シンプルさと柔軟性を意識して設計されており、複数のプラットフォーム向けアプリにスムーズに統合されます。

用途

  • カスタムページ付きテーブルの実装
  • リスト内の大きなデータセットをナビゲートする
  • 使いやすいページナビゲーションの構築
  • 応答性のあるデータグリッドの作成
  • 離散ページを使用した無限スクロールの実装
  • データ集約型アプリケーションにおけるUXの向上

主な機能

  • 数値ページインジケーター
  • 設定可能なページ範囲表示
  • 前方および後方ナビゲーションのサポート
  • ListView や DataTable との簡単な統合
  • テーマまたはプロパティを介したカスタマイズ可能なスタイル
  • クロスプラットフォーム互換性

適している対象

  • データ集約型UIを構築する開発者
  • 軽量なページネーションを必要とするチーム
  • カスタムテーブルページネーションを必要とするアプリ
  • 複数のプラットフォーム向けのFlutterプロジェクト
  • ページネーションの表示形式を制御したいUIデザイナー

注意事項

  • データの読み込みを自動的に処理しない
  • ページ変更のための手動状態管理が必要です
  • 数値によるページネーションに限定(無限スクロールなし)
  • 非常に大きなページ数に対して最適化されていない
  • アクセシビリティ機能の組み込みサポートなし

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Pager

Numeric pagination suitable for multiple cases, such as, custom paged table.

Getting started

You should ensure that you add the pager as a dependency in your flutter project.

dependencies:
 pager: ^0.0.6

Example Project

There is a example project in the example folder. Check it out. Otherwise, keep reading to get up and running.

Usage

Need to include the import the package to the dart file where it will be used, use the below command,

import 'package:pager/pager.dart';

Pager

Basic Widget


new Pager(
            currentPage: _currentPage,
            totalPages: 5,
            onPageChanged: (page) {},
          ),

Example 1

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Pagination Example"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
              height: 200,
              margin: const EdgeInsets.all(32),
              color: Colors.blue,
              child: Center(
                child: Text(
                  "PAGE: $_currentPage",
                  style: const TextStyle(color: Colors.white, fontSize: 20),
                ),
              ),
            ),
            Pager(
              currentPage: _currentPage,
              totalPages: 5,
              onPageChanged: (page) {
                setState(() {
                  _currentPage = page;
                });
              },
            ),
          ],
        ),
      ),
    );
  }
}

Complete example 2

import 'package:flutter/material.dart';
import 'package:pager/pager.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Pagination Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({
    Key? key,
  }) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  late int _currentPage;
  late int _itemsPerPage;
  List<int> pages = [5, 10, 18, 50, 100];
  late int _totalPages;
  final int _totalElements = 100;
  @override
  void initState() {
    super.initState();
    _currentPage = 1;
    _itemsPerPage = pages.first;
    _totalPages = (_totalElements / _itemsPerPage) as int;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Pagination Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Pagination Example'),
        ),
        body: Padding(
          padding: const EdgeInsets.all(32.0),
          child: Center(
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                Container(
                  height: 180,
                  width: 400,
                  color: Colors.blue,
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.spaceAround,
                    children: [
                      Text(
                        "TOTAL ELEMENT: $_totalElements",
                        style:
                            const TextStyle(color: Colors.white, fontSize: 18),
                      ),
                      Text(
                        "PAGE: $_currentPage",
                        style:
                            const TextStyle(color: Colors.white, fontSize: 18),
                      ),
                      Text(
                        "ITEMS PER PAGE: $_itemsPerPage",
                        style:
                            const TextStyle(color: Colors.white, fontSize: 18),
                      ),
                      Text(
                        "TOTAL PAGES: $_totalPages",
                        style:
                            const TextStyle(color: Colors.white, fontSize: 18),
                      ),
                    ],
                  ),
                ),
                const SizedBox(height: 32),
                Pager(
                  currentItemsPerPage: _itemsPerPage,
                  currentPage: _currentPage,
                  totalPages: _totalPages,
                  onPageChanged: (page) {
                    setState(() {
                      _currentPage = page;
                    });
                  },
                  showItemsPerPage: true,
                  onItemsPerPageChanged: (itemsPerPage) {
                    setState(() {
                      _itemsPerPage = itemsPerPage;
                      _totalPages = (_totalElements / _itemsPerPage).ceil();
                      _currentPage = 1;
                    });
                  },
                  itemsPerPageList: pages,
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。