Home > Back-end >  I am having trouble rendering a container and an expanded panel list flutter
I am having trouble rendering a container and an expanded panel list flutter

Time:12-19

I'm trying to render a container and an expanded panel list together in a single page. Bellow is my code snippet. Thank you all

SingleChildScrowView:
Child:
 ExpansionPanelList(
              children: [
                ExpansionPanel(
                  isExpanded: _isOpen[0],
                  headerBuilder: (context, isOpen) {
                    return Text("Activities");
                  },
                  body: SingleChildScrollView(
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        _myListView(),
                        // _myListView(),
                      ],
                    ),
                  ),
                ),
                ExpansionPanel(
                  isExpanded: _isOpen[1],
                  headerBuilder: (context, isOpen) {
                    return Text("Ports");
                  },
                  body: Text("Test!!!"),
                )
              ],
              expansionCallback: (i, isOpen) {
                setState(() {
                  _isOpen[i] = !isOpen;
                });
              },
            )
)

_myListView widget is shown below. _myListView widget is shown below. _myListView widget is shown below. _myListView widget is shown below.



 Widget _myListView() {
    return MediaQuery.removePadding(
      context: context,
      removeTop: true,
      child: ListView(
        shrinkWrap: true,
        physics: ScrollPhysics(),
        children: List1.keys.map((String key) {
          return new CheckboxListTile(
            title: new Text(key),
            value: List1[key],
            activeColor: Colors.black,
            checkColor: Colors.white,
            onChanged: (bool value) {
              setState(() {
                List1[key] = value;
              });
            },
          );
        }).toList(),
      ),
    );
  }

CodePudding user response:

you just wrap container and expansion panel with the column and make your expansion panel Expanded

Column(
    children: [
      Container(
        height: 200,
        color: Colors.green,
      ),
      Expanded(
        child: SingleChildScrollView(
          child: Column(
            children: [
              // your expension panel
            ],
          ),
        ),
      )
    ],
  )
  • Related