【发布时间】:2021-06-03 14:44:16
【问题描述】:
我有一个问题清单,当我检查一个问题时,我想滚动到下一个问题。 这在 Flutter 中怎么可能?或者我应该使用什么小部件? 或者也许有一个图书馆已经在做我需要的?
非常感谢任何帮助或建议!
这是我的代码:
Widget _buildBody() {
var dbHelper = DBHelper();
return ListView.builder(
padding: EdgeInsets.all(10),
itemCount: 1,
itemBuilder: (BuildContext context, int index) {
return Card(
child: Column(
children: questionsList
?.map(
(question) => Row(
children: [
Expanded(
flex: 4,
child: Text(
"${question.questionNumber}. ${question.questionDescription}",
style: TextStyle(fontSize: 20),
),
),
Expanded(
flex: 1,
child: IconButton(
icon: Icon(Icons.check_circle_outline),
color: question.questionAnswer == 1
? Colors.green
: Colors.grey,
iconSize: 60,
onPressed: () {
setState(
() {
question.questionAnswer = 1;
dbHelper.updateQuestion(question);
print('Yes');
},
);
},
),
),
Expanded(
flex: 1,
child: IconButton(
icon: Icon(Icons.close),
color: question.questionAnswer == 0
? Colors.red
: Colors.grey,
iconSize: 60,
onPressed: () {
setState(
() {
question.questionAnswer = 0;
dbHelper.updateQuestion(question);
print('No');
},
);
},
),
),
],
),
)
?.toList() ??
[],
),
);
},
);
}
提前致谢!
【问题讨论】:
-
它很容易做到,你只需要一个滚动监听器。如果您还需要帮助,请告诉我