【问题标题】:How can I make a flutter app full screen? [duplicate]如何让 Flutter 应用全屏显示? [复制]
【发布时间】:2021-05-07 12:39:39
【问题描述】:

我从不同的网站和文章中尝试了不同的东西,但我无法摆脱顶部的黑条

【问题讨论】:

  • 请添加您的代码

标签: flutter flutter-layout fullscreen android-fullscreen


【解决方案1】:

有人问过here

tl;博士 将这段代码添加到 main 函数中,在 runApp() 之前

SystemChrome.setEnabledSystemUIOverlays([])

代码:

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  SystemChrome.setEnabledSystemUIOverlays(<SystemUiOverlay>[]);

  runApp(MyApp());
}

你想做的画面会是这样的

class SplashScreen extends StatefulWidget {
  @override
  _SplashScreenState createState() => _SplashScreenState();
}

class _SplashScreenState extends State<SplashScreen> {
  @override
  Widget build(BuildContext context) {
    return Scaffold();
  }
}

结果:

没有SystemChrome.setEnabledSystemUIOverlays([])

【讨论】:

  • 我仍然得到顶部的黑条
  • 如果你想要真正的全屏,那么你需要在Scaffold之前删除SafeArea
  • 我该怎么做?
  • 让我编辑我的答案
  • 我不能让它工作你能帮我吗我对此有点新
猜你喜欢
  • 2018-03-20
  • 1970-01-01
  • 2010-10-05
  • 2019-11-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多