DolDurma
DolDurma

Reputation: 17303

Flutter colorize background ExpansionPanelList

in this below flutter ExpansionPanelList widget i'm trying to colorize white background to other color such as indigo, i can't find any documentation or helpful link to achieve that

ExpansionPanelList(
  expansionCallback: (int index, bool isExpanded) {
    setState(() {
      _categoryExpansionStateMap[_categoryExpansionStateMap.keys
          .toList()[index]] = !isExpanded;
    });
  },
  children: <ExpansionPanel>[
    ExpansionPanel(
        headerBuilder: (BuildContext context, bool isExpanded) {
          return ListTile(
            contentPadding: EdgeInsets.all(3.0),
            leading: Container(
              padding:
                  EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 0.0),
              decoration: BoxDecoration(
                  border: Border(
                      left: BorderSide(
                          width: 3.0, color: Colors.white54))),
              child: Icon(
                Icons.account_circle,
                size: 30.0,
                color: Colors.black,
              ),
            ),
            title: ListTile(
              contentPadding: EdgeInsets.all(0.0),
              title: Text(
                Strings.yourBasicInformation,
                style: TextStyle(
                    color: Colors.black,
                    fontSize: 14.0,),
              )
            ),
          );
        },
        body: Biography(),
        isExpanded: _categoryExpansionStateMap["Biography"]),
  ],
),

Upvotes: 0

Views: 1623

Answers (1)

Fellipe Malta
Fellipe Malta

Reputation: 3510

You can try two moves. One. Wrap your ExpansionPanelList in a Container and pass the color in the Container, I think it should work, I don't know the rest of your code.

The second move it to wrap your ExpansionPanelList in a Theme component. Pass a data, then call ThemeData().copyWith(canvasColor: Colors.white). Then, it'll look like this:

    Theme(
        data: ThemeData().copyWith(canvasColor: Colors.white),
        child: ExpansionPanelList(
          expansionCallback: (int index, bool isExpanded) {
            setState(() {
              _categoryExpansionStateMap[_categoryExpansionStateMap.keys
                  .toList()[index]] = !isExpanded;
            });
          },
          children: <ExpansionPanel>[
            ExpansionPanel(
                headerBuilder: (BuildContext context, bool isExpanded) {
                  return ListTile(
                    contentPadding: EdgeInsets.all(3.0),
                    leading: Container(
                      padding:
                      EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 0.0),
                      decoration: BoxDecoration(
                          border: Border(
                              left: BorderSide(
                                  width: 3.0, color: Colors.white54))),
                      child: Icon(
                        Icons.account_circle,
                        size: 30.0,
                        color: Colors.black,
                      ),
                    ),
                    title: ListTile(
                        contentPadding: EdgeInsets.all(0.0),
                        title: Text(
                          Strings.yourBasicInformation,
                          style: TextStyle(
                            color: Colors.black,
                            fontSize: 14.0,),
                        )
                    ),
                  );
                },
                body: Biography(),
                isExpanded: _categoryExpansionStateMap["Biography"]),
          ],
        ),
      )

Upvotes: 1

Related Questions