Reputation: 41
I am making an quiz app but option are in list format. But I want the option in grid view.
...(_questions[_questionIndex]['answers']
as List<Map<String, Object>>)
.map(
(answer) => Answer(
answerText: answer['answerText'],
answerColor: answerWasSelected
? answer['score']
? Colors.green
: Colors.red
: null,
answerTap: () {
// if answer was already selected then nothing happens onTap
if (answerWasSelected) {
return;
}
My option are in this format: Current option format
But I want them in 2*2 format ( 2 row and two columns).
Upvotes: 0
Views: 163
Reputation: 154
Something like this
GridView.builder(
itemCount: data.length,`// length of the list
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2 ),
itemBuilder: (BuildContext context, int index) {
return new Card(
child: new GridTile(
footer: new Text(data[index]['name']),
child: new Text(data[index]
['image']),
),
);
},
),
Upvotes: 0