【问题标题】:Flutter fullscreen app. Getting rid of the blank white space at the bottom of the app on androidFlutter 全屏应用。摆脱android上应用程序底部的空白区域
【发布时间】:2018-06-18 20:08:51
【问题描述】:

我使用SystemChrome.setEnabledSystemUIOverlays([]); 让我的 Flutter 应用全屏显示。

状态栏已经消失了,但我在导航栏原来所在的底部看到了这个空白。

【问题讨论】:

  • 另外,fullscreen_mode 插件也有同样的问题。
  • @Aasiz 你是怎么解决这个问题的?我现在正面临,请帮忙。
  • 下面的答案是正确的。只需在脚手架小部件中设置 resizeToAvoidBottomPadding: false 即可。

标签: flutter android-fullscreen flutter-layout android-navigation-bar


【解决方案1】:

您可以在Scaffold 上将resizeToAvoidBottomPadding 设置为false

Scaffold(
  resizeToAvoidBottomPadding: false,
  appBar: new AppBar(),
);

【讨论】:

  • @Rémi 它确实隐藏了底部导航栏,但在触摸屏幕后,导航栏再次出现并永远存在。我知道在 Android 中,我们可以做 getWindow().setFlags(...) 但我正在考虑一些方法来处理它。
【解决方案2】:

这段代码对我有用,谢谢

@override
 Widget build(BuildContext context) {
    SystemChrome.setEnabledSystemUIOverlays([]);
    return Scaffold(
      resizeToAvoidBottomPadding: false
    )
 }

resizeToAvoidBottomPadding 已被弃用,现在您必须使用 resizeToAvoidBottomInset

更新代码如下:

@override
 Widget build(BuildContext context) {
    SystemChrome.setEnabledSystemUIOverlays([]);
    return Scaffold(
      resizeToAvoidBottomInset: false
    )
 }

【讨论】:

    【解决方案3】:

    我使用了 resizeToAvoidBottomPadding = false 但有时导航栏所在的位置有白色填充。不一致,有时显示,有时不显示

    【讨论】:

      【解决方案4】:

      使用 SystemChrome.setEnabledSystemUIOverlays([]);在您的小部件中,它将完美运行:

      @override
        Widget build(BuildContext context) {
      
          // To make this screen full screen.
          // It will hide status bar and notch.
          SystemChrome.setEnabledSystemUIOverlays([]);
      
          // full screen image for splash screen.
          return Container(
                  child: new Image.asset('assets/splash.png', fit: BoxFit.fill));
            }
          }
      

      记得导入这个

      import 'package:flutter/services.dart';
      

      【讨论】:

        猜你喜欢
        • 2017-06-09
        • 2018-12-28
        • 2022-06-29
        • 1970-01-01
        • 2019-01-09
        • 2018-10-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多