-
Notifications
You must be signed in to change notification settings - Fork 11
initiallyOpenedControllersIndexes does not work properly #17
Copy link
Copy link
Open
Description
Map<String, ExpandedTileController> tilesControllers = {};
class MyWidget extends StatefulWidget {
const MyWidget({
super.key,
this.expandedAll = false,
});
@override
_MyWidgetState createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
List<String> myList = [ 'orange', 'apple', 'lemon'];
@override
Widget build(BuildContext context) {
return ExpandedTileList.builder(
itemCount: myList.length,
initiallyOpenedControllersIndexes: widget.expandedAll ? [0, 1, 2, 3, 4, 5] : [],
itemBuilder: (expContext, expIndex, expCon) {
if (!tilesControllers.containsKey('$expIndex-${myList[expIndex]}')) {
tilesControllers['$expIndex-${myList[expIndex]}'] = expCon;
}
});
}
);
if I call the controllers from another widget like this
for (final controller in tilesControllers.values) {
controller.toggle();
}
initiallyOpenedControllersIndexes does not work properly.
If expandedAll is true, meaning all the indexes are in the array, only 2 controllers are set in the tilesControllers map, and calling them from a loop does not collapse all of them, only the ones with an assigned controller, of course.
On the other hand, if expandedAll is false, meaning the array is empty, or if I remove initiallyOpenedControllersIndexes entirely, all the controllers are set, and if I call toggle them from a loop they work.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels