单击按钮时,在无尽的ListView中显示更多数据-Flutter

发布于 2025-02-14 02:11:41 字数 175 浏览 0 评论 0原文

当我单击“扑来”按钮时,如何在列表视图或网格视图中显示更多数据? (使用ListView无止境)我想做与下面的生命线游戏图像相同。 谢谢你! 生命线游戏

How to show more data in list view or grid view when I click a button in Flutter? (With listview is endless) I want to do the same as the Lifeline Game image below.
Thank you!
Lifeline Game

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

从此见与不见 2025-02-21 02:11:42

创建一个问题列表

List<String> allQuestions = ['question1', 'question2', 'question3'];

使用listView.builder创建列表视图,

ListView.builder(
  itemCount: allQuestions.length,
  itemBuilder: (context, i) {
    return Container(child: Text(allQuestions[i]));
   },
)

如果将项目添加到列表并设置状态,则将重新创建列表,

allQuestions.add("question4");
setState((){});

这将填充第四个问题作为最后一个项目。

Create a List of questions

List<String> allQuestions = ['question1', 'question2', 'question3'];

Create a list view using a ListView.builder

ListView.builder(
  itemCount: allQuestions.length,
  itemBuilder: (context, i) {
    return Container(child: Text(allQuestions[i]));
   },
)

If you add items to the list and set state the list will be recreated

allQuestions.add("question4");
setState((){});

This will populate the 4th question as the last item.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文