相关疑难解决方法(0)

未收到堆栈边界外的手势响应

我正在尝试实现一个可重新调整大小的小部件,在角落处带有手柄。角手柄将溢出Stack其宽度/高度的一半。

问题:句柄的外部不报告手势事件,而内部工作正常。

这是故意的,或者我做错了什么。如果这是预期行为,那么下一步该怎么做。

示例代码

      Widget build(BuildContext context) {
        return Scaffold(
          backgroundColor: Colors.green,
          body: Transform.translate(
            offset: boxOffset,
            child: Stack(
              overflow: Overflow.visible,
              fit: StackFit.expand,
              children: <Widget>[
                Container(
                  width: 100.0,
                  height: 100.0,
                  color: Colors.red,
                ),
                Positioned(
                  left: 100.0 - 20.0,
                  top: 100.0 - 20.0,
                  child: GestureDetector(
                    onTap: () {print("tapped");},
                    child: Container(
                      width: 80.0,
                      height: 80.0,
                      color: Colors.blue,
                    ),
                  ),
                )
              ],
            ),
          )
        );
    }
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

dart flutter

9
推荐指数
1
解决办法
1052
查看次数

溢出框,溢出的部分无法响应按钮?

我需要用垂直溢出的 TabBar 项目构建一个底部导航栏吗?所以我尝试使用OverflowBox,它看起来很有用。但是还有另一个问题?溢出的部分无法响应按钮。

那么我应该怎么做才能使 GestureDetector 有效?或者你有其他方法来构建这样的底部导航栏?非常感谢!

这是屏幕截图

这是 main.dart:

    import 'package:flutter/material.dart';

    void main() => runApp(new MyApp());

    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return new MaterialApp(
          title: 'Flutter Demo',
          theme: new ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: new MyHomePage(title: 'OverflowBox touch test'),
        );
      }
    }

    class MyHomePage extends StatefulWidget {
      MyHomePage({Key key, this.title}) : super(key: key);

      final String title;

      @override
      _MyHomePageState createState() => new _MyHomePageState();
    }

    List<Color> _colors = [
      Colors.blue,
      Colors.green,
      Colors.yellow,
    ];

    class _MyHomePageState extends State<MyHomePage> …
Run Code Online (Sandbox Code Playgroud)

dart flutter

8
推荐指数
1
解决办法
982
查看次数

堆叠中负 Y 偏移的印刷机抖动问题

我在堆栈中有两个小部件。下面将对此进行演示。

导航栏

第二个小部件是一个按钮,它位于具有负 Y 轴的定位小部件中。

问题是溢出了,无法点击。我有什么办法可以解决这个问题吗?

Stack(
    fit: StackFit.expand,
    overflow: Overflow.visible,
    clipBehavior: Clip.none,
    alignment: AlignmentDirectional.topCenter,
    children: [
      ClipRRect(
        borderRadius: BorderRadius.all(Radius.circular(29)),
        child: ClipPath(
          clipper: NavbarClipper(),
          child: Container(
            color: Colors.white,
          ),
        ),
      ),
      Positioned(
        top: -30,
        child: Container(
          width: context.dynamicHeight(0.16),
          height: context.dynamicWidth(0.16),
          child: FittedBox(
            child: FloatingActionButton(
              onPressed: () {},
              backgroundColor: Colors.orange,
              child: Icon(Icons.ac_unit),
            ),
          ),
        ),
      )
    ],
  )
Run Code Online (Sandbox Code Playgroud)

谢谢。

flutter

5
推荐指数
1
解决办法
821
查看次数

标签 统计

flutter ×3

dart ×2