I'm trying to create an ExpansionPanel with data from a map. I have my data being created from an API in a separate function and am passing the data in with this.branchData. I've attached my code below:
class RunList extends StatefulWidget {
// Creates a list of packages.
final Map branchData;
// Defines what needs to be passed into the class. Needs the branchNames list.
RunList(this.branchData, {Key? key}) : super(key: key);
@override
// Creates mutable state for that widget at a given location in the tree.
// Returns _ProjectDropdownState() which extends the State.
State<RunList> createState() => _RunListState();
}
However, I'm trying to access branchData in a separate function called generateItems, but I get the error 'Undefined name 'branchData'.' I'm able to access branchData using widget.branchData, however, I can't use that in generateItems. Is there any way I can get branchData elsewhere in my code to be usable in generateItems? I've attached generateItems below:
List<Item> generateItems(int numberOfItems) {
List<Item> runData = [];
// Create Item
var run = new Item (
headerValue: branchData["refs/heads/main"][branchData["branchRuns"]["refs/heads/main"][0]].commitTitle,
expandedValue: 'Nothing to see yet...',
);
runData.add(run);
return runData;
}