Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I try to create two ExpansionTile if one tile open the another tile will close and the but in my code the tow Tile will automatically generate space

Here I create two ExpansionTile they automatically create space between them

SizedBox(
                height: 500,
                child: Column(
                  children: [
                    Expanded(
                      child: SingleChildScrollView(
                        child: ExpansionTile(
                          title: const Text('developer'),
                          children: List.generate(
                            successState.developerList.length,
                            (index) => EmployeeTileWidget(
                                employee: successState.developerList[index]),
                          ),
                        ),
                      ),
                    ),
                    Expanded(
                      child: SingleChildScrollView(
                        child: ExpansionTile(
                          title: const Text('testerList'),
                          children: List.generate(
                            successState.testerList.length,
                            (index) => EmployeeTileWidget(
                                employee: successState.testerList[index]),
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
            ),


flutter```

`the two ExpansionTile will automatically generate space `

I try to create two expand and collapse widget if one open the another stay on the bottom of the SizedBox. but in my case the one ExpansionTile will open the another one will go the end of the list so if need to scroll the end of the list to open the another ExpansionTile

I need to create if one ExpansionTile will open the another one will stay the bottom of the SizedBox if the if one ExpansionTile close then the another one will go back to the normal position

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

wrap your parent widget with scrollable widget and let the children has it own height.

see the code

SizedBox(
      height: 500,
      child: Column(children: [
        ConstrainedBox(
          constraints: BoxConstraints(maxHeight: 300),
          child: SingleChildScrollView(
              child: ExpansionTile(
            title: const Text('testerList'),
            children: List.generate(
              3,
              (index) => Text("ssdasdas"),
            ),
          )),
        ),
        ExpansionTile(
          title: const Text('testerList'),
          children: List.generate(
            7,
            (index) => Text("ssdasdas"),
          ),
        ),
      ]),
    )

cant attach any image, since Stackoverflow error. you can check this plyaground.

result:

https://dartpad.dev/?id=c3f0c6f4dcc5d0705d32b7ba10f4a429

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading