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

パッケージ詳細v1.2.1

lazy_load_indexed_stack

IndexedStack を拡張して遅延読み込みを可能にするパッケージ。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
1.3万
いいね数
101
Pub ポイント
160

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

flutter pub add lazy_load_indexed_stack

パッケージ概要

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

IndexedStack を拡張して、子要素の遅延読み込みを可能にする Flutter パッケージです。現在表示されているウィジェットのみがビルドされレンダリングされることを保証し、複数のページや重いウィジェットを持つアプリのパフォーマンスを向上させます。各タブに複雑なコンテンツを含むタブインターフェースやナビゲーションに最適です。必要なときにのみウィジェットの作成を延期することで、メモリを効率的に管理し、初期ロード時間とリソース使用量を削減します。

用途

  • 大量コンテンツを含むタブインターフェース
  • マルチページレイアウトにおけるパフォーマンス最適化
  • 初期アプリロード時間を短縮する
  • 動的コンテンツ切り替え
  • メモリ効率の良いナビゲーション
  • 複雑なウィジェットの遅延レンダリング

主な機能

  • IndexedStack を拡張する
  • 子要素の遅延読み込み
  • オンデマンドでのウィジェット作成
  • パフォーマンスの向上
  • メモリ効率
  • シンプルな統合

適している対象

  • アプリのパフォーマンス最適化を行う開発者
  • 複数のタブまたはスクリーンを持つアプリ
  • 効率的なレンダリングを必要とする複雑なUI
  • IndexedStack を使用するプロジェクト
  • リソース管理に焦点を当てるチーム

注意事項

  • IndexedStack 内の子ウィジェットに制限
  • 慎重な状態管理が必要になる場合があります
  • 即時のレンダリング要件には適していません
  • 予測可能なナビゲーションパターンと併用するのが最適です
  • ウィジェットのライフサイクルの理解が必要です

元の README

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

CI Pub

lazy_load_indexed_stack

A package that extends IndexedStack to allow for lazy loading and provides enhanced control for reloading specific child widgets.

Motivation

If you use the IndexedStack with bottom navigation, all the widgets specified in the children of the IndexedStack will be built.

Moreover, if the widget requires API requests or database access, or has a complex UI, the IndexedStack build time will be significant.

Therefore, we created an extended IndexedStack that builds the required widget only when it is needed and returns the pre-built widget when it is needed again.

Features

  • Lazy Loading: The main feature of LazyLoadIndexedStack is to build children widgets only when they are needed, reducing initial load time.
  • Preloading: With the preloadIndexes parameter, you can specify indexes of children that should be built in advance, even if they are not currently visible. This is useful for preloading widgets that are likely to be needed soon.
  • Auto Disposal: The autoDisposeIndexes parameter allows specific children to be automatically disposed of when they are no longer visible. When these children are accessed again, they will be rebuilt from scratch. This is useful for cases where widgets hold significant state or require resetting when revisited.

Usage

You can use LazyLoadIndexedStack in the same way as IndexedStack, with additional options for preloading and auto dispose. If an index is included in both preloadIndexes and autoDisposeIndexes, it will be preloaded initially but disposed when it becomes invisible and rebuilt when accessed again.

Basic Example
class MainPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {
  int _index = 0;

  @override
  Widget build(final BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: LazyLoadIndexedStack(
          index: _index,
          preloadIndexes: [1, 2],
          autoDisposeIndexes: [2, 3],
          children: [
            Page1(), // Load by initial index
            Page2(), // Preloaded initially
            Page3(), // Preloaded initially but disposed when other index is selected
            Page4(), // Not preloaded and disposed when other index is selected
          ],
        ),
        bottomNavigationBar: BottomNavigationBar(
          onTap: (index) {
            setState(() => _index = index);
          },
          currentIndex: _index,
          items: [
            BottomNavigationBarItem1(),
            BottomNavigationBarItem2(),
            BottomNavigationBarItem3(),
            BottomNavigationBarItem4(),
          ],
        ),
      ),
    );
  }
}

See more details in Example or API reference!

カテゴリー

ソースリポジトリ

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