【问题标题】:Scaffold Status Bar Blocking Button Touch脚手架状态栏遮挡按钮触摸
【发布时间】:2021-04-05 21:37:30
【问题描述】:

虽然我处于全屏模式,其中状态栏被隐藏,但我右上角的菜单按钮仍然没有收到触摸。您可以在图片中看到我选择了正在接收触摸的顶部栏。

我的菜单按钮的一半正在接收触摸,而另一半没有。

我还拍了 Flutter InspectorWidget Select Mode

的照片

我还添加了我的自定义按钮代码。仅供参考:

class RoundIconButton extends StatelessWidget {
  RoundIconButton({
    Key key,
    @required this.onPressed,
    @required this.icon,
    this.fillColor = Colors.transparent,
  }) : super(key: key);

  final Icon icon;
  final Function onPressed;
  final Color fillColor;

  @override
  Widget build(BuildContext context) {
    return RawMaterialButton(
      child: icon,
      onPressed: onPressed,
      shape: CircleBorder(),
      fillColor: fillColor,
      constraints: BoxConstraints.tightFor(height: 50.0, width: 50.0),
    );
  }
}

【问题讨论】:

  • 用 safeArea 小部件包裹你的脚手架主体
  • 用 safeArea 包裹脚手架主体也会将我的小部件向下移动。我不想那样。

标签: flutter user-interface touch statusbar scaffold


【解决方案1】:

你必须用 SafeArea 包裹你的脚手架,

没有 SafeArea 布局看起来像:

带有 SafeArea 的布局看起来像:

【讨论】:

  • 您可以清楚地看到我有一个全屏应用程序。我不能使用安全区期间
【解决方案2】:

使用 脚手架在子 SafeArea 和 SafeArea 内插入所有页面 安全区域有凹槽和底栏避免

Scaffold(
  body: SafeArea(
    child: ...........
    ...........
  ),
),

【讨论】:

    猜你喜欢
    • 2011-12-17
    • 1970-01-01
    • 1970-01-01
    • 2011-12-08
    • 2018-03-31
    • 2021-10-07
    • 1970-01-01
    • 2014-05-20
    • 1970-01-01
    相关资源
    最近更新 更多