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

パッケージ詳細v0.1.0

flutter_lazy_indexed_stack

遅延読み込みが可能な `IndexedStack` を公開する Flutter パッケージ。

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

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

flutter pub add flutter_lazy_indexed_stack

パッケージ概要

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

組み込みの IndexedStack を拡張して、子要素の遅延読み込みをサポートする Flutter パッケージです。現在表示されているウィジェットのみがビルドされ、レンダリングされることを保証し、高コストのウィジェットを多数含む大きなスタックにおけるパフォーマンスを向上させます。メモリ効率とオンデマンドレンダリングが重要となるシナリオに最適です。このパッケージは IndexedStack と同じ API を維持しつつ、遅延初期化を追加しており、既存プロジェクトへの統合がスムーズです。

用途

  • 大規模なタブインターフェース
  • メモリ効率の良いナビゲーション
  • 動的コンテンツ切り替え
  • オンデマンドでのウィジェットレンダリング
  • 重いコンポーネントを備えた複雑なUI

主な機能

  • スタックの子要素の遅延読み込み
  • IndexedStack と同じ API
  • パフォーマンスの向上
  • メモリ使用量の削減
  • シームレスな統合

適している対象

  • 開発者がUIパフォーマンスを最適化しています
  • 多数のタブや画面を持つアプリ
  • 重いウィジェットを使用する IndexedStack を使用するプロジェクト
  • ページネーション重視のアプリケーション
  • 非常にインタラクティブなダッシュボード

注意事項

  • 直ちの子レンダリング要件には適していません
  • スタックベースのレイアウトに限定
  • 慎重な状態管理が必要になる場合があります
  • 安定したインデックス値と併用するのが最適です
  • デフォルトではアニメーション付きの遷移をサポートしていません

元の README

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

Lazy Indexed Stack 😴🥞

pub ci License: MIT style: very good analysis

A Flutter package that exposes an IndexedStack that can be lazily loaded.

IndexedStack is a widget that shows its children one at a time, preserving the state of all the children. But it renders all the children at once.

With LazyIndexedStack, you can load the children lazily, and only when they are needed. This comes in handy if you have a lot of children, and you don't want to load them all at once or if you have a child that loads content asynchronously.

Usage

The LazyIndexedStack API is the same as IndexedStack. A basic implementation requires two parameters:

  • A List<Widget> of children that are going to be lazy loaded under the hood.
  • An int index that indicates which child is going to be shown.

Example

class HomePage extends StatefulWidget {
  const HomePage({super.key, required this.title});

  final String title;

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int index = 0;

  void changeIndex(int newIndex) => setState(() => index = newIndex);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Column(
        children: [
          Expanded(
            child: LazyIndexedStack(
              index: index,
              children: List.generate(3, (i) => Text('$i')),
            ),
          ),
          BottomNavigationBar(
            currentIndex: index,
            onTap: changeIndex,
            items: const [
              BottomNavigationBarItem(
                icon: Icon(Icons.filter_1),
                label: '1',
              ),
              BottomNavigationBarItem(
                icon: Icon(Icons.filter_2),
                label: '2',
              ),
              BottomNavigationBarItem(
                icon: Icon(Icons.filter_3),
                label: '3',
              ),
            ],
          ),
        ],
      ),
    );
  }
}

Refer to the example to see the usage of LazyIndexedStack.

カテゴリー

ソースリポジトリ

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