Skip to content

ExpansionPanelCallback shows incorrect state while opening and closing ExpansionPanelList. #74114

@kuyaC

Description

@kuyaC

Hello, I might have found a bug/error in the framework. I describe how the actual results differ from the ones I expected.
(copied from where I posted this first https://stackoverflow.com/questions/65743515/flutter-expansionpanellist-radio-callback-returns-wrong-value)


The line I marked with the comment (in CAPS) doesn't do what it's expected to do.

console output when I toggle a certain ExpansionPanelRadio() (of language english for example):

  • I open the ExpansionPanelRadio(): flutter: english false (<-- should be true, right?)
  • I close the ExpansionPanelRadio(): flutter: english true (<-- should be false, right?)

console output when language english is selected, and I click another one (for example mandarin):

  1. flutter: mandarin false (<--this one went from close to open, shouldn't it return true??)
  2. flutter: english false (<--this one went from open to close)

Why do they both say false, when obviously one opened and the other one closed? Both panels were in different states before, and also after the change.

With this information^^, HOW am I supposed to know WHICH ExpansionPanelRadio() just got tapped?

            List<String> languages = Languages.languageToImagePath.keys.toList();

            return SingleChildScrollView(
              child: ExpansionPanelList.radio(
                initialOpenPanelValue: targetLanguage, //see value in ExpansionPanelRadio
                expansionCallback: (int panelIndex, bool isExpanded) {
                  print('${languages[panelIndex]} $isExpanded'); //<-- HEEEEEEERRREEEEE
                },
                children: languages.map<ExpansionPanel>((language) {
                  return ExpansionPanelRadio(
                    value: language,
                    headerBuilder: (context, bool isExpanded) { //and what's this bool for?
                      return Text(language);
                    },
                    body: Text('Choose writing system(s) todo...'),
                  );
                }).toList(),
              ),
            );

I think these might be errors/bugs in the framework, but I wanted to ask here on stackoverflow before reporting it.
Maybe I just don't understand how these Widgets are supposed to be used.
Any help is appreciated.

I first thought ExpansionPanelList.radio might be the perfect Widget for what I intend to do, but it looks like I just have to make my own custom Widget

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: material designflutter/packages/flutter/material repository.found in release: 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions