简体   繁体   English

如何使 InkWell 的飞溅可见?

[英]How can I make InkWell's splash visible?

Environment环境

  • Flutter 1.12.13+hotfix.9 Flutter 1.12.13+hotfix.9
  • Dart 2.7.2 Dart 2.7.2

Question问题

I made code like this below.我在下面编写了这样的代码。

I find when I tap it, 'InkWell.onTap' shows up in the console, but splash animation (= the animation expanding like a wave) does not happen.我发现当我点击它时,控制台中会显示“InkWell.onTap”,但不会发生飞溅 animation(= animation 像波浪一样扩展)。 Could you help me understand why I cannot see splash animation?你能帮我理解为什么我看不到飞溅 animation 吗?

Sample样本

在此处输入图像描述

InkWell(
  splashColor: Colors.blueAccent,
  onTap: () {
    print('${DateTime.now()}| InkWell.onTap');
  },
  child: Container(
    color: Colors.lightBlue[100],
    child: Row(
      children: <Widget>[
        Expanded(
          child: Column(
            children: <Widget>[
              Padding(
                padding: EdgeInsets.all(8.0),
                child: Container(
                  decoration: BoxDecoration(
                    color: Colors.lightBlue[50],
                    border: Border.all(),
                  ),
                  child: Padding(
                    padding: EdgeInsets.all(8.0),
                    child: Align(
                      alignment: Alignment.centerLeft,
                      child: Text('Text1'),
                    ),
                  ),
                ),
              ),
              Padding(
                padding: EdgeInsets.only(
                    left: 16, top: 8, right: 8, bottom: 8),
                child: Align(
                  alignment: Alignment.centerLeft,
                  child: Text('Text2'),
                ),
              ),
            ],
          ),
        ),
      ],
    ),
  ),
)

Additional info附加信息

The code above only makes a light blue square which you can find 5 in the screenshot.上面的代码只制作了一个浅蓝色方块,您可以在屏幕截图中找到 5。

One person suggested this question is a possible duplicate of this .有人建议这个问题可能与问题重复。 However, I still have a problem.但是,我仍然有一个问题。

I think the answers basically say that "Move the color property to outside of InkWell Widget", but my case has multiple colors ( Colors.lightBlue[100] and Colors.lightBlue[50] ), so I cannot simply move color to outside. I think the answers basically say that "Move the color property to outside of InkWell Widget", but my case has multiple colors ( Colors.lightBlue[100] and Colors.lightBlue[50] ), so I cannot simply move color to outside. Please correct me if I misunderstand something.如果我误解了什么,请纠正我。

To get the ripple effect a Material widget must be a direct ancestor of InkWell with the placement of your InkWell right now your entire screen would have a ripple effect I am not sure if this is the effect you wanted or not.要获得涟漪效果, Material小部件必须是InkWell的直接祖先,现在您的InkWell的位置您的整个屏幕都会产生涟漪效果,我不确定这是否是您想要的效果。

 Material(
          color: Colors.lightBlue[100],
          child: InkWell(
            splashColor: Colors.blueAccent,
            onTap: () {
              print('${DateTime.now()}| InkWell.onTap');
            },
            child: Row(
              children: <Widget>[
                Expanded(
                  child: Column(
                    children: <Widget>[
                      Padding(
                        padding: EdgeInsets.all(8.0),
                        child: Container(
                          decoration: BoxDecoration(
                            color: Colors.lightBlue[50],
                            border: Border.all(),
                          ),
                          child: Padding(
                            padding: EdgeInsets.all(8.0),
                            child: Align(
                              alignment: Alignment.centerLeft,
                              child: Text('Text1'),
                            ),
                          ),
                        ),
                      ),
                      Padding(
                        padding: EdgeInsets.only(
                            left: 16, top: 8, right: 8, bottom: 8),
                        child: Align(
                          alignment: Alignment.centerLeft,
                          child: Text('Text2'),
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
        ),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter:如何制作圆形 PopupMenuButton 的 InkWell? - Flutter: how can I make a rounded PopupMenuButton's InkWell? Flutter InkWell splash strength - 如何让它在整个应用程序中更加可见? - Flutter InkWell splash strength - how to make it more visible globally for the entire app? 如何为 gridview 的每个元素制作不同的墨水池(点击)以导航到单独的页面? - how can i make different inkwell's (on tap) for each element of the gridview, to navigate to separate pages? 仅在按下的窗口小部件位于另一个InkWell小部件内时才显示InkWell闪屏 - Showing the InkWell splash only on pressed widget when it's inside another InkWell widget 如何摆脱InkWell小部件上的动画? - How can I get rid of the animation on the InkWell widget? 应用栏上的 InkWell 高度飞溅 - InkWell height splash on appbar InkWell 和 GestureDetector,如何让它们工作? - InkWell and GestureDetector, how to make them work? 如何让我的 Inkwell 悬停在我的菜单项上工作? - How do i make my Inkwell onhover work on my menu items? Flutter:如何在每次相机移动时更新 InkResponse 或 InkWell 字符串值? - Flutter: How can I update my InkResponse or InkWell string value every time my camera moves? Flutterinkwell - 如何仅代理某些特定事件并传递其他事件? - Flutter inkwell - how can I only proxy some specific event and pass other events?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM