如何单击扩展标题?

发布于 2025-01-22 16:05:03 字数 295 浏览 1 评论 0 原文

我的意思是,当标题被轻拍并扩展/倒塌时,我想转到另一个视图。

这是我的代码:

ExpansionTile(
                  title: categories.isEmpty
                      ? Text('no items')
                      : Text(categories[i].name),
                  children: getSubCategories(i),
                );

I mean, I want to go to another view when the title is tapped and expand/collapse when the icon in ExpansionTile is tapped.

here's my code:

ExpansionTile(
                  title: categories.isEmpty
                      ? Text('no items')
                      : Text(categories[i].name),
                  children: getSubCategories(i),
                );

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

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

发布评论

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

评论(2

究竟谁懂我的在乎 2025-01-29 16:05:03

扩展Tile 按设计扩展,如果您希望孩子们可以选择一个具有输入的窗口小部件,或者用 gesturedetector 将其包装。

ExpansionTile(title: Text('Expansion tile'), children: [
  ListTile(
    leading: const Text('List tile'),
    onTap: () => Navigator.of(context).push(
      MaterialPageRoute(
        builder: (BuildContext context) {
          return Container();
        },
      ),
    ),
  ),
  GestureDetector(
    child: const Text('Wrapped'),
    onTap: () => Navigator.of(context).push(
      MaterialPageRoute(
        builder: (BuildContext context) {
          return Container();
        },
      ),
    ),
  )
])

ExpansionTile expands by design, if you want the children to be tappable either choose a widget that has onTap or wrap it with GestureDetector.

ExpansionTile(title: Text('Expansion tile'), children: [
  ListTile(
    leading: const Text('List tile'),
    onTap: () => Navigator.of(context).push(
      MaterialPageRoute(
        builder: (BuildContext context) {
          return Container();
        },
      ),
    ),
  ),
  GestureDetector(
    child: const Text('Wrapped'),
    onTap: () => Navigator.of(context).push(
      MaterialPageRoute(
        builder: (BuildContext context) {
          return Container();
        },
      ),
    ),
  )
])
∞琼窗梦回ˉ 2025-01-29 16:05:03

得到了解决方案。只需将文本小部件包裹在墨水中即可。

Got the solution. Just wrap the text Widget into an Inkwell.

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