【问题标题】:flutter on click open and collapse dropdown点击打开和折叠下拉菜单时颤动
【发布时间】:2019-07-17 07:38:30
【问题描述】:

我正在尝试在颤振中进行可折叠,但我不确定到底需要写什么,我有以下代码

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Welcome to WesterAf'),
        backgroundColor: Colors.lightBlueAccent,
        elevation: 0.0,
        iconTheme: new IconThemeData(color: Colors.lightBlueAccent),
      ),
      body: ExpansionTile(
        title: Text('Early Bird Registation'),
        // leading: Icon(Icons.local_pizza),
        trailing: Icon(Icons.expand_more),
        children: <Widget>[
          Column(
            children: <Widget>[
              new Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  Text('general registation'),
                  Text('yesllow'),
                  Text('mitukula vekatesh'),
                  new Radio(value: 0, groupValue: 23, onChanged: null),
                ],
              )
            ],
          ),
          Column(
            children: <Widget>[
              new Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  Text('general registation'),
                  Text('yesllow'),
                  Text('venkey'),
                  new Radio(value: 0, groupValue: 23, onChanged: null),
                ],
              )
            ],
          )
        ],
      ),
    );
  }

我得到了下拉列表,但我需要超过 1 个,下面的图片正是我想要的。

【问题讨论】:

    标签: flutter dart flutter-animation


    【解决方案1】:

    目前您正在构建一个 ExpansionTile。

    如果您想要多个 ExpansionTiles,请使用 ExpansionPanelList

    它需要一个 ExpansionTiles 列表作为子项,并得到一个 expansionCallback 函数,如果点击了 ExpansionPanel,你可以在哪里处理,应该发生什么。 例如设置打开面板的状态:

    expansionCallback: (int index, bool isExpanded) {
      setState(() {
        _data[index].isExpanded = !isExpanded;
      });
    },
    

    查看官方文档,有一个代码示例。

    【讨论】:

    • @Mitukula 如果此答案适用于您的问题,请考虑将此答案标记为正确
    猜你喜欢
    • 1970-01-01
    • 2014-09-15
    • 2023-03-10
    • 1970-01-01
    • 2012-07-06
    • 2012-05-15
    • 2018-09-23
    • 2017-07-23
    • 1970-01-01
    相关资源
    最近更新 更多