flutter treeview库的onTap函数如何使用
How use onTap function of treeview library flutter
您好,我正在使用这个 pubdev 包 https://pub.dev/packages/tree_view/example . My problem is that when I use the onTap function the expanded does not work, I was checking the library and I noticed that it is because of this code, however I do not know how to solve it or if there is another way to access that function from the library from the widget. Any ideas
如果你注意到当onTap函数与empty不同时,toggleExpanded()函数不适用
有什么想法吗??
您需要使用 startExpanded property of the TreeView 小部件自行控制扩展。
首先,您的 StatefulWidget
中有一个布尔变量(比如 _startExpanded
),用于保存扩展状态,您可以将其设置为默认状态(例如,false
).
bool _startExpanded = false;
然后,您将变量传递给 TreeView
小部件:
TreeView(
startExpanded: _startExpanded,
children: _getChildList(documentList),
),
展开,调用:
setState((){
_startExpanded = true;
});
要关闭,请调用:
setState((){
_startExpanded = false;
});
您好,我正在使用这个 pubdev 包 https://pub.dev/packages/tree_view/example . My problem is that when I use the onTap function the expanded does not work, I was checking the library and I noticed that it is because of this code, however I do not know how to solve it or if there is another way to access that function from the library from the widget. Any ideas
如果你注意到当onTap函数与empty不同时,toggleExpanded()函数不适用
有什么想法吗??
您需要使用 startExpanded property of the TreeView 小部件自行控制扩展。
首先,您的 StatefulWidget
中有一个布尔变量(比如 _startExpanded
),用于保存扩展状态,您可以将其设置为默认状态(例如,false
).
bool _startExpanded = false;
然后,您将变量传递给 TreeView
小部件:
TreeView(
startExpanded: _startExpanded,
children: _getChildList(documentList),
),
展开,调用:
setState((){
_startExpanded = true;
});
要关闭,请调用:
setState((){
_startExpanded = false;
});