Hi I am using this pubdev package
If you notice it when the onTap function is different from empty, the toggleExpanded() function does not apply
So any ideas??
CodePudding user response:
You need to control the expansion yourself using the startExpanded property of the TreeView widget.
First, you have a boolean variable (say _startExpanded
) in your StatefulWidget
that hold the state of the expansion and you can set it the default state (for instance, false
).
bool _startExpanded = false;
Then, you pass the variable to your TreeView
widget:
TreeView(
startExpanded: _startExpanded,
children: _getChildList(documentList),
),
To expand, you call:
setState((){
_startExpanded = true;
});
To close, you call:
setState((){
_startExpanded = false;
});