Skip to content

Commit 6113c66

Browse files
committed
docs: update README to add notes for preloadIndexes
1 parent 29d2983 commit 6113c66

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Test and Lint](https://github.com/okaryo/lazy_load_indexed_stack/actions/workflows/test-and-lint.yml/badge.svg)](https://github.com/okaryo/lazy_load_indexed_stack/actions/workflows/test-and-lint.yml)
1+
[![CI](https://github.com/okaryo/lazy_load_indexed_stack/actions/workflows/ci.yml/badge.svg)](https://github.com/okaryo/lazy_load_indexed_stack/actions/workflows/ci.yml)
22
[![Pub](https://img.shields.io/pub/v/lazy_load_indexed_stack)](https://pub.dev/packages/lazy_load_indexed_stack)
33

44
# lazy_load_indexed_stack
@@ -13,6 +13,10 @@ Moreover, if the widget requires API requests or database access, or has a compl
1313

1414
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.
1515

16+
## Features
17+
* **Lazy Loading**: The main feature of `LazyLoadIndexedStack` is to build children widgets only when they are needed, reducing initial load time.
18+
* **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.
19+
1620
## Usage
1721
You can use `LazyLoadIndexedStack` in the same way as `IndexedStack`.
1822

@@ -31,10 +35,12 @@ class _MainPageState extends State<MainPage> {
3135
home: Scaffold(
3236
body: LazyLoadIndexedStack(
3337
index: _index,
38+
preloadIndexes: const [3],
3439
children: [
3540
Page1(),
3641
Page2(),
3742
Page3(),
43+
Page4(), // index3 is preloaded
3844
],
3945
),
4046
bottomNavigationBar: BottomNavigationBar(
@@ -46,6 +52,7 @@ class _MainPageState extends State<MainPage> {
4652
BottomNavigationBarItem1(),
4753
BottomNavigationBarItem2(),
4854
BottomNavigationBarItem3(),
55+
BottomNavigationBarItem4(),
4956
],
5057
),
5158
),

0 commit comments

Comments
 (0)