You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-1Lines changed: 8 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
[](https://github.com/okaryo/lazy_load_indexed_stack/actions/workflows/test-and-lint.yml)
@@ -13,6 +13,10 @@ Moreover, if the widget requires API requests or database access, or has a compl
13
13
14
14
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.
15
15
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
+
16
20
## Usage
17
21
You can use `LazyLoadIndexedStack` in the same way as `IndexedStack`.
18
22
@@ -31,10 +35,12 @@ class _MainPageState extends State<MainPage> {
31
35
home: Scaffold(
32
36
body: LazyLoadIndexedStack(
33
37
index: _index,
38
+
preloadIndexes: const [3],
34
39
children: [
35
40
Page1(),
36
41
Page2(),
37
42
Page3(),
43
+
Page4(), // index3 is preloaded
38
44
],
39
45
),
40
46
bottomNavigationBar: BottomNavigationBar(
@@ -46,6 +52,7 @@ class _MainPageState extends State<MainPage> {
0 commit comments