0

这发生在我使用颤振 2.5.3 的 Android 12 上

使用时

SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);

顶部状态栏是隐藏的,但它所在的空间完全是黑色且无法使用。 在此处输入图像描述

这是我正在使用的代码

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

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

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) => Scaffold(
        body: Column(
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      );
}

我想知道我是否会遗漏一些东西

4

2 回答 2

0

您必须从设置中授予应用程序使用全屏模式的权限,只需在设置中搜索全屏

于 2022-01-14T15:57:09.077 回答
0

如果有人仍在寻找解决方案,请在 github 中查看此问题:https ://github.com/flutter/flutter/issues/46486

链接响应中提供的解决方案对我有用:https ://github.com/flutter/flutter/issues/46486#issuecomment-654796115

只需将以下行添加到 'android/app/src/main/res/values/styles.xml'

<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
于 2022-02-18T15:31:42.257 回答