showModalBottomSheet 如何使用数据进行导航

发布于 2025-01-15 16:45:19 字数 1697 浏览 1 评论 0原文

输入图片此处描述在此处输入图像描述

当单击列表视图中的项目时,我想将信息移动到底部工作表,但我找不到路。 导航器.push( 语境, 材质页面路由( 构建者:(上下文)=>自定义BottomSheet(上下文), ),我尝试过,但没有成功,我该如何解决这个问题

return Expanded(
                      child: ListView.builder(
                          shrinkWrap: true,
                          scrollDirection: Axis.vertical,
                          itemCount: coinListForDisplay.length,
                          itemBuilder: (context, index) {
                            return InkWell(
                              onTap: (() {
                                customBottomSheet(context);
                              }),
                              child: ListViewCard(
                                name: coinListForDisplay[index].name,
                                symbol: coinListForDisplay[index].symbol,
                                imageUrl: coinListForDisplay[index].imageUrl,
                                price:
                                    coinListForDisplay[index].price.toDouble(),
                                change:
                                    coinListForDisplay[index].change.toDouble(),
                                changePercentage: coinListForDisplay[index]
                                    .changePercentage
                                    .toDouble(),
                              ),
                            );
                          }),
                    );```

enter image description hereenter image description here

When the item in the listview is clicked, I want to move the information to the bottom sheet, but I couldn't find the way.
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => customBottomSheet(context),
),i tried but it didn't work how can i solve this problem

return Expanded(
                      child: ListView.builder(
                          shrinkWrap: true,
                          scrollDirection: Axis.vertical,
                          itemCount: coinListForDisplay.length,
                          itemBuilder: (context, index) {
                            return InkWell(
                              onTap: (() {
                                customBottomSheet(context);
                              }),
                              child: ListViewCard(
                                name: coinListForDisplay[index].name,
                                symbol: coinListForDisplay[index].symbol,
                                imageUrl: coinListForDisplay[index].imageUrl,
                                price:
                                    coinListForDisplay[index].price.toDouble(),
                                change:
                                    coinListForDisplay[index].change.toDouble(),
                                changePercentage: coinListForDisplay[index]
                                    .changePercentage
                                    .toDouble(),
                              ),
                            );
                          }),
                    );```

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

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

发布评论

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

评论(1

要走干脆点 2025-01-22 16:45:19

您可以像这样在参数中传递数据。
在您的自定义底部工作表中,使用

CustomBottomSheet(BuildContext context,yourData){
    //Your code
}

在您的 onTap 函数中使用

CustomBottomSheet(context,yourData);

You can pass data in parameters like this.
In you custom bottom sheet, use

CustomBottomSheet(BuildContext context,yourData){
    //Your code
}

And in your onTap function use

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