【问题标题】:Flutter ExpansionTile Extention button placementFlutter ExpansionTile 扩展按钮位置
【发布时间】:2021-03-22 11:26:17
【问题描述】:

我有一个要展开的容器,我单击向下箭头按钮。如果您查看这张图片 (https://gyazo.com/eeaa9fb8d3f93d5f6f190ced2389e2e1),您会看到我已经添加了一个我想要单击的按钮,以便它会展开。但是,一旦我将容器包装在扩展拼贴中,它会在其左侧添加一个箭头,如您在这张图片中看到的 (https://gyazo.com/c8ec072e511f7f0d03ff925c2d8f158d)。

我的代码在这里,结果在第二张图片中

Container(

    width: MediaQuery.of(context).size.width * 0.97,
    margin: EdgeInsets.only(top: 10, bottom: 10),
    padding: EdgeInsets.only(top: 10, left: 20, right: 20),
    decoration: BoxDecoration(
        color: Color(0xff0A213D),
        borderRadius:
        BorderRadius.vertical(bottom: Radius.circular(3))),
    child: ExpansionTile(

        title: Column(children: < Widget > [

            Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: < Widget > [
                    Container(
                        margin: EdgeInsets.only(top: 15),
                        child:
                        Text("Obiectiv numarul 1", style: TextStyle(fontSize: 22, color: Colors.white), ), ),
                    IconButton(
                        iconSize: 35,
                        color: Color(0xff6c7a8b),
                        icon: Icon(Icons.create_outlined),
                        onPressed: () {

                        },
                    ),
                ], ),
            Align(
                alignment: Alignment.centerRight,
                child: Text('5 dec 2020', style: TextStyle(fontSize: 15, color: Color(0xffdadada)), )),
            Container(
                margin: EdgeInsets.only(top: 10, bottom: 10),
                color: Colors.white,
                child: StepProgressIndicator(

                    totalSteps: 5,
                    currentStep: 2,
                    size: 6,
                    selectedColor: Color(0xff2f80ed),
                    unselectedColor: Colors.grey,
                )
            ),
            Align(
                alignment: Alignment.centerRight,
                child: IconButton(
                    iconSize: 45,
                    color: Color(0xff2f80ed),
                    icon: Icon(Icons.keyboard_arrow_down_outlined),
                    onPressed: () {

                    },
                )),

        ], ),
        children: < Widget > [
            Text('expanded text')
        ],
    )
)

【问题讨论】:

    标签: flutter flutter-layout


    【解决方案1】:

    设置 Container() 或 SizedBox() 的尾随参数将删除第二个箭头,或者您可以将 IconButton() 设置为 ExpansionTile 的尾随:

    【讨论】:

    • 我现在确实删除了箭头,我想问是否有任何方法可以设置箭头的 onclick 以展开框
    • 我最近实现了一个自定义的 ExpansionTile 类,它也应该在这种情况下工作stackoverflow.com/a/48935106/7441113
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-12
    • 2018-12-24
    • 1970-01-01
    相关资源
    最近更新 更多