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
+11-8
Original file line number
Diff line number
Diff line change
@@ -3,23 +3,25 @@
3
3
4
4
# lazy_load_indexed_stack
5
5
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.
7
7
8
8
## Motivation
9
9
10
-
If you use the IndexedStack with bottom navigation, all the widgets specified in the children of the IndexedStack will be built.
10
+
If you use the IndexedStack with bottom navigation, all the widgets specified in the children of the IndexedStack will be built.
11
11
12
-
Moreover, if the widget requires API requests or database access, or has a complex UI, the IndexedStack build time will be significant.
12
+
Moreover, if the widget requires API requests or database access, or has a complex UI, the IndexedStack build time will be significant.
13
13
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.
15
15
16
16
## Features
17
17
***Lazy Loading**: The main feature of `LazyLoadIndexedStack` is to build children widgets only when they are needed, reducing initial load time.
18
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
+
***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.
19
20
20
21
## 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 auto dispose.
22
23
24
+
### Basic Example
23
25
```dart
24
26
class MainPage extends StatefulWidget {
25
27
@override
@@ -36,11 +38,12 @@ class _MainPageState extends State<MainPage> {
0 commit comments