我正在制作一個測驗應用程式,但選項是串列格式。但我想要網格視圖中的選項。
...(_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;
}
我的選項是這種格式: 當前選項格式
但我希望它們采用 2*2 格式(2 行兩列)。
uj5u.com熱心網友回復:
像這樣的東西
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']),
),
);
},
),
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/387095.html
