Flutter

Flutter,第1张

Flutter

您可以使用ExpandablePanelList来执行展开折叠视图。使用expandingCallback保持活动状态以执行展开或折叠。这是工作示例

class TestExpandableView extends StatefulWidget {  @override  _TestExpandableViewState createState() => _TestExpandableViewState();}class _TestExpandableViewState extends State<TestExpandableView> {  int _activeMeterIndex;  @override  Widget build(BuildContext context) {    return Container(      child: new ListView.builder(          itemCount:  2,          itemBuilder: (BuildContext context, int i) { return Card(   margin:   const EdgeInsets.fromLTRB(10.0, 15.0, 10.0, 0.0),   child: new ExpansionPanelList(     expansionCallback: (int index, bool status) {       setState(() {         _activeMeterIndex = _activeMeterIndex == i ? null : i;       });     },     children: [       new ExpansionPanel(isExpanded: _activeMeterIndex == i,headerBuilder: (BuildContext context,    bool isExpanded) =>new Container(    padding:    const EdgeInsets.only(left: 15.0),    alignment: Alignment.centerLeft,    child: new Text(      'list-$i',    )),body: new Container(child: new Text('content-$i'),),),     ],   ), );          }),    );  }}


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/4926737.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-13
下一篇2022-11-12

发表评论

登录后才能评论

评论列表(0条)

    保存