如何在颤抖的导航抽屉中水平展开折叠项

时间:2020-04-04 12:46:18

标签: flutter dart drawer

我想在导航抽屉中水平添加展开的折叠项。是否有任何示例或github代码。我在下面添加了图片,以便您能够理解我要说的话。enter image description here

2 个答案:

答案 0 :(得分:1)

您可以制作自定义抽屉。

Check this example

您可以执行类似的操作以达到图像中的效果。

希望这会有所帮助!

答案 1 :(得分:1)

您可以使用扩展图块实现此结果:

  bool _isExpanded = false;

  @override
  Widget build(BuildContext context) {


    return Scaffold(
      appBar: AppBar(
        title: Text('Expansion Tile'),
      ),
      drawer: Drawer(
        child: Column(
          children: <Widget>[
            ExpansionTile(
              onExpansionChanged: (b) {
                setState(() {
                  _isExpanded = !_isExpanded; //using set state just to exemplify
                });
              },
              title: Text('Expand items'),
              trailing: Padding(
                padding: const EdgeInsets.only(right: 100),
                child: Icon(_isExpanded
                    ? Icons.keyboard_arrow_up
                    : Icons.keyboard_arrow_down),
              ),
              children: <Widget>[
                Padding(
                  padding: const EdgeInsets.only(left: 30, right: 60),
                  child: ExpansionTile(
                    title: Text('First child'),
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.only(left: 30, right: 60),
                  child: ExpansionTile(
                    title: Text('Second child'),
                  ),
                ),
              ],
            )
          ],
        ),
      ),
    );
  }

结果:

enter image description here