Skip to content

Commit 06a8e83

Browse files
committed
docs: update README.md
1 parent b67c64f commit 06a8e83

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,25 @@
33

44
# lazy_load_indexed_stack
55

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

88
## Motivation
99

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

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

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.
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. With the newly added features, you can now also force specific child widgets to reload or manage widget updates dynamically.
1515

1616
## Features
1717
* **Lazy Loading**: The main feature of `LazyLoadIndexedStack` is to build children widgets only when they are needed, reducing initial load time.
1818
* **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+
* **Forced Reloading**: Using the `forceReloadIndexes` parameter, you can specify which child widgets should be forcibly rebuilt when needed. This is helpful for dynamic data loading or resetting specific widgets.
1920

2021
## Usage
21-
You can use `LazyLoadIndexedStack` in the same way as `IndexedStack`.
22+
You can use `LazyLoadIndexedStack` in the same way as `IndexedStack`, with additional options for preloading and forced reloading.
2223

24+
### Basic Example
2325
```dart
2426
class MainPage extends StatefulWidget {
2527
@override
@@ -36,11 +38,12 @@ class _MainPageState extends State<MainPage> {
3638
body: LazyLoadIndexedStack(
3739
index: _index,
3840
preloadIndexes: const [3],
41+
forceReloadIndexes: const [1, 2], // Force reload for index 1 and 2
3942
children: [
4043
Page1(),
41-
Page2(),
42-
Page3(),
43-
Page4(), // index3 is preloaded
44+
Page2(), // index 1 will be reloaded as specified
45+
Page3(), // index 2 will also be reloaded
46+
Page4(), // index 3 is preloaded
4447
],
4548
),
4649
bottomNavigationBar: BottomNavigationBar(

0 commit comments

Comments
 (0)