i have an object that looks like this,
marketOptions: {option1: {optionValue: 'Yes', optionId: `${match.id}`+ '333'+ `1`}, option2:{optionValue: 'No', optionId: `${match.id}`+ '333'+ `2` }},
I want to loop through "option1", "option2", etc and collect the data in "optionValue", my first attempt below was to get the object from my Firestore database and assign it to a variable called "marketList" and then using a Listview.builder loop through the list but i keep getting the error "the getter "optionValue" was called on null", how can i achieve what i am looking for?
var marketList = thesnapshot.data()['marketOptions'];
var listCount = thesnapshot.data()['marketOptions'].length;
Container(height: listCount * MediaQuery.of(context).size.height * 11.8 / 100, child: ListView.builder(physics: const NeverScrollableScrollPhysics(),
itemCount: listCount,
itemBuilder: (context, index) {
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: < Widget > [Container(height: MediaQuery.of(context).size.height * 10 / 100, child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: < Widget > [
Container(width: MediaQuery.of(context).size.width * 40 / 100, child: Text(marketList[index].optionValue, style: TextStyle(
color: Color(0xffffffff),
fontFamily: 'Montserrat',
fontSize: MediaQuery.of(context).size.height * 1.8 / 100,
fontWeight: FontWeight.w600))),
User contributions licensed under CC BY-SA 3.0