efficient_indexed_stack

Last updated:

0 purchases

efficient_indexed_stack Image
efficient_indexed_stack Images
Add to Cart

Description:

efficient indexed stack

efficient_indexed_stack #
Flutter's IndexedStack widget initializes the given children immediately.
This package handle initialization process so that children gets built lazily.
Minimal usage;
EfficientIndexedStack(
index: index,
itemCount: itemCount,
itemBuilder: (_, index) => MyCoolWidget(
index,
key: GlobalKey(), // << IMPORTANT
),
),
copied to clipboard
How many children initialized? #
You can set keepAliveDistance parameter to decide how many indices must be alive.
EfficientIndexedStack(
keepAliveDistance: 4,
index: activeIndex,
itemCount: itemCount,
itemBuilder: (_, index) => MyCoolWidget(
index,
key: GlobalKey(), // << IMPORTANT
),
),
copied to clipboard
Which indices are alive? #
You can set indexCalculationStrategy parameter to decide which indices should be alive.

IndexCalculationStrategy.aroundCurrentIndex

aroundCurrentIndex option initializes the current index and the indices before and after that based on keepAliveDistance
EfficientIndexedStack(
indexCalculationStrategy: IndexCalculationStrategy.aroundCurrentIndex,
keepAliveDistance: 3,
index: 4,
itemCount: 10,
itemBuilder: (_, index) => MyCoolWidget(
index,
key: GlobalKey(), // << IMPORTANT
),
),

// 0, (1), (2), (3), [4], (5), (6), (7), 8, 9
copied to clipboard

IndexCalculationStrategy.beforeCurrentIndex

EfficientIndexedStack(
indexCalculationStrategy: IndexCalculationStrategy.beforeCurrentIndex,
keepAliveDistance: 3,
index: 4,
itemCount: 10,
itemBuilder: (_, index) => MyCoolWidget(
index,
key: GlobalKey(), // << IMPORTANT
),
),

// 0, (1), (2), (3), [4], 5, 7, 8, 9
copied to clipboard

IndexCalculationStrategy.afterCurrentIndex

EfficientIndexedStack(
indexCalculationStrategy: IndexCalculationStrategy.afterCurrentIndex,
keepAliveDistance: 3,
index: 4,
itemCount: 10,
itemBuilder: (_, index) => MyCoolWidget(
index,
key: GlobalKey(), // << IMPORTANT
),
),

// 0, 1, 2, 3, [4], (5), (7), (8), 9
copied to clipboard
Once you update the current index. Only the new indices are initialized and the others gets disposed.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.