Flutter手势检测器在堆栈小部件中不起作用

沙纳兹·拉海姆(Shahnaz Raheem)

我正在使用stack小部件在图像上显示后退箭头按钮。它的显示,但问题是它不是可轻触的,这意味着Gesturededector无法在Stack上工作。

我的密码

  Stack(
      children: <Widget>[

        Container(
          height: height * 0.4,
          decoration: BoxDecoration(
            image: DecorationImage(
              image: AssetImage(
                'assets/images/place2.jpg',
              ),
              fit: BoxFit.fill,
            ),
          ),
        ),
        GestureDetector(
          behavior: HitTestBehavior.translucent,
          onTap: () => print("first container"),
          child: Align(
            alignment: Alignment.topLeft,
            child: Container(
              margin: EdgeInsets.only(left: width * 0.03),
              padding: EdgeInsets.only(top: statusBarHeight * 2),

              child: Icon(
                Icons.arrow_back_ios,
                size: 25,
                color: Colors.white,
              ),
            ),
          ),
        ),

        SingleChildScrollView(
          child: Padding(
            padding: EdgeInsets.only(top: height * 0.3),
            child: SingleChildScrollView(
              child: ClipRRect(
                borderRadius: BorderRadius.only(
                    topRight: Radius.circular(30),
                    topLeft: Radius.circular(30)),
                child: Container(
                  decoration: BoxDecoration(
                    color: Colors.white,
                  ),
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: <Widget>[
                      SizedBox(
                        height: height * 0.05,
                      ),
                      Container(
                        width: width,
                        margin: EdgeInsets.only(left: width * 0.03),
                        child: Text(
                          'NYC Food Festival',
                          textAlign: TextAlign.left,
                          style: TextStyle(fontSize: 30),
                        ),
                      ),
                      SizedBox(
                        height: height * 0.02,
                      ),
                      Container(
                        margin: EdgeInsets.only(left: width * 0.03),
                        child: Row(
                          children: <Widget>[
                            Icon(
                              Icons.calendar_today,
                              size: 20,
                              color: Color(0xff808080),
                            ),
                            SizedBox(width: width * 0.02), // give it width
                            Column(
                              children: <Widget>[
                                Text(
                                  'Sat, May 25, 2020',
                                  style: TextStyle(
                                      color: Color(0xff000000),
                                      fontWeight: FontWeight.bold,
                                      fontSize: 15),
                                ),
                              ],
                            )
                          ],
                        ),
                      ),
                      SizedBox(
                        height: height * 0.02,
                      ),
                      Container(
                        margin: EdgeInsets.only(left: width * 0.03),
                        child: Row(
                          children: <Widget>[
                            Icon(
                              Icons.attach_money,
                              size: 20,
                              color: Color(0xff808080),
                            ),
                            SizedBox(width: width * 0.02), // give it width
                            Column(
                              children: <Widget>[
                                Text(
                                  '25,000 PKR',
                                  style: TextStyle(
                                      color: Color(0xff000000),
                                      fontWeight: FontWeight.bold,
                                      fontSize: 15),
                                ),
                              ],
                            )
                          ],
                        ),
                      ),
                      SizedBox(
                        height: height * 0.02,
                      ),
                      SizedBox(
                        height: height * 0.02,
                      ),
                      Container(
                        width: width,
                        margin: EdgeInsets.only(left: width * 0.03),
                        child: Text(
                          'Snaps',
                          textAlign: TextAlign.left,
                          style: TextStyle(fontSize: 25),
                        ),
                      ),
                      SizedBox(
                        height: height * 0.02,
                      ),
                      Container(
                          child: Column(
                            children: <Widget>[
                              CarouselSlider(
                                options: CarouselOptions(
                                  autoPlay: true,
                                  aspectRatio: 2.0,
                                  enlargeCenterPage: true,
                                ),
                                items: imageSliders,
                              ),
                            ],
                          )),
                      SizedBox(
                        height: height * 0.02,
                      ),
                      Container(
                        width: width,
                        margin: EdgeInsets.only(left: width * 0.03),
                        child: Text(
                          'About',
                          textAlign: TextAlign.left,
                          style: TextStyle(fontSize: 25),
                        ),
                      ),
                      SizedBox(
                        height: height * 0.02,
                      ),
                      Container(
                          padding: EdgeInsets.only(
                              right: width * 0.03, left: width * 0.03),
                          child: DescriptionTextWidget(
                              text:
                                  "Flutter is Google’s mobile UI framework for crafting high-quality native interfaces on iOS and Android in record time. Flutter works with existing code, is used by developers and organizations around the world, and is free and open source.")
                      ),
                      SizedBox(
                        height: height * 0.02,
                      ),
                      Container(
                        width: width,
                        margin: EdgeInsets.only(left: width * 0.03),
                        child: Text(
                          'Included',
                          textAlign: TextAlign.left,
                          style: TextStyle(fontSize: 25),
                        ),
                      ),
                      SizedBox(
                        height: height * 0.02,
                      ),
                      Included(),
                      SizedBox(
                        height: height * 0.01,
                      ),
                      Included(),
                      SizedBox(
                        height: height * 0.01,
                      ),
                      Included(),
                      SizedBox(
                        height: height * 0.01,
                      ),




                    ],
                  ),
                ),
              ),
            ),
          ),
        ),
        Positioned(
          bottom: 0,
          left: 0,
          right: 0,
          child: Container(
            height: 100,
            decoration: BoxDecoration(
              // color: Color.fromARGB(110, 255, 255, 255),
              borderRadius: BorderRadius.only(
                topLeft: Radius.circular(20),
                topRight: Radius.circular(20),
              ),
              gradient: LinearGradient(
                colors: [
                  Color.fromARGB(30, 255, 255, 255),
                  Color.fromARGB(255, 255, 255, 255),
                ],
                begin: Alignment.topCenter,
                end: Alignment.bottomCenter,
              ),
            ),
            child: Center(
              child: InkWell(
                child: Container(
                  padding: EdgeInsets.symmetric(
                    horizontal: 80,
                    vertical: 20,
                  ),
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(30),
                    color: Colors.blueAccent,
                  ),
                  child: Text(
                    "BOOK NOW",
                    style: TextStyle(
                        fontWeight: FontWeight.bold,
                        fontSize: 20,
                        color: Colors.white),
                  ),
                ),
                onTap: () {
                  return print("Tap");
                },
              ),
            ),
          ),
        ),
      ],
    )

导航时,我需要将其用作后退按钮,但它无法正常工作,然后进行测试,我只是在onTap上打印了一个值,但它也无法正常工作,因此我也尝试添加behaviour

Dipesh KC

您是否可以尝试将GestureDectector放在SingleChildScrollView之后的堆栈中。

我猜SingleChildScrollView位于GestureDetector上方,因为它是一个堆栈。

SingleChildScrollView(),
GestureDetector(),

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

videoView片段中的Android手势检测器

来自分类Dev

Flutter:如何在手势检测器中暂时禁用onTap?

来自分类Dev

Flutter如何在使用手势检测器进行onTap之后更改SVG

来自分类Dev

如何使用Libgdx手势检测器

来自分类Dev

滑动手势识别器不起作用

来自分类Dev

颤振在手势检测器中添加文本

来自分类Dev

滑动手势在UITableViewCell中不起作用

来自分类Dev

默认手势事件在 googlemap 中不起作用

来自分类Dev

应用变换小部件时的手势检测

来自分类Dev

为什么点击手势识别器在绝对布局中不起作用?

来自分类Dev

在堆栈中的两个小部件之间传递所有手势

来自分类Dev

Flutter 是否有“滚动手势识别器”小部件?

来自分类Dev

颤抖如何使用手势检测器在onTap之后更改图像

来自分类Dev

如何使用手势检测器“ onTap”导航到其他页面?

来自分类Dev

如何使用手势检测器和动画移动视图

来自分类Dev

墨水瓶/手势检测器保持和释放

来自分类Dev

为什么手势监听器不起作用?

来自分类Dev

当在透明的UIView上使用手势进行子类化以检测其背后的对象时,手势不起作用

来自分类Dev

在动画UIView上点击手势不起作用

来自分类Dev

Android多击手势不起作用

来自分类Dev

鼠标手势在 Ubuntu 18.04 上不起作用

来自分类Dev

Appium滑动手势在Android列表中不起作用

来自分类Dev

ios中动画期间,imageview的手势不起作用

来自分类Dev

Bootstrap Modal中的Google Maps。平移/缩放鼠标手势不起作用

来自分类Dev

Appium滑动手势在Android列表中不起作用

来自分类Dev

Iconbuttons onTap 方法或任何其他 onTap 在 flutter 中的堆栈小部件内不起作用吗?

来自分类Dev

使用颤动中的手势检测器导航到其他页面时,颤动中的黑屏。说多个英雄共享同一标签

来自分类Dev

我正在尝试将手势检测器放在警报对话框中以导航到下一页,但警报框溢出

来自分类Dev

当搜索显示控制器显示结果时,iOS滑动手势不起作用

Related 相关文章

  1. 1

    videoView片段中的Android手势检测器

  2. 2

    Flutter:如何在手势检测器中暂时禁用onTap?

  3. 3

    Flutter如何在使用手势检测器进行onTap之后更改SVG

  4. 4

    如何使用Libgdx手势检测器

  5. 5

    滑动手势识别器不起作用

  6. 6

    颤振在手势检测器中添加文本

  7. 7

    滑动手势在UITableViewCell中不起作用

  8. 8

    默认手势事件在 googlemap 中不起作用

  9. 9

    应用变换小部件时的手势检测

  10. 10

    为什么点击手势识别器在绝对布局中不起作用?

  11. 11

    在堆栈中的两个小部件之间传递所有手势

  12. 12

    Flutter 是否有“滚动手势识别器”小部件?

  13. 13

    颤抖如何使用手势检测器在onTap之后更改图像

  14. 14

    如何使用手势检测器“ onTap”导航到其他页面?

  15. 15

    如何使用手势检测器和动画移动视图

  16. 16

    墨水瓶/手势检测器保持和释放

  17. 17

    为什么手势监听器不起作用?

  18. 18

    当在透明的UIView上使用手势进行子类化以检测其背后的对象时,手势不起作用

  19. 19

    在动画UIView上点击手势不起作用

  20. 20

    Android多击手势不起作用

  21. 21

    鼠标手势在 Ubuntu 18.04 上不起作用

  22. 22

    Appium滑动手势在Android列表中不起作用

  23. 23

    ios中动画期间,imageview的手势不起作用

  24. 24

    Bootstrap Modal中的Google Maps。平移/缩放鼠标手势不起作用

  25. 25

    Appium滑动手势在Android列表中不起作用

  26. 26

    Iconbuttons onTap 方法或任何其他 onTap 在 flutter 中的堆栈小部件内不起作用吗?

  27. 27

    使用颤动中的手势检测器导航到其他页面时,颤动中的黑屏。说多个英雄共享同一标签

  28. 28

    我正在尝试将手势检测器放在警报对话框中以导航到下一页,但警报框溢出

  29. 29

    当搜索显示控制器显示结果时,iOS滑动手势不起作用

热门标签

归档