状态栏顶部出现奇怪的填充

Flutter strange padding on top of status bar

我想删除状态栏顶部的奇怪填充。我只是在使用图像,并想将该图像放在状态栏后面的屏幕顶部。这样状态栏图标应该覆盖在图像上。

简单地使用脚手架作为父部件,然后简单的图像。屏幕截图在这里!

图标没有正确重叠图像,顶部有白色填充!

我现在正在使用 Android 模拟器,有人能帮我弄清楚我错过了什么吗?

class PreSignInScreen extends StatelessWidget {
  final PreSignInController controller = Get.put(PreSignInController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        child: Column(
          mainAxisSize: MainAxisSize.max,
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            const SizedBox(
              height: 10,
            ),
            getRedCarBox(context),
          ]
      );
    )
}

感谢并预支

试试这个:

@override
 Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () async {
        return false;
      },
      child: Scaffold(
        body: SafeArea(
          top: false,
          bottom: false,
          child: _buildBody(),
        ),
      ),
    );
  }

试试下面的代码,我试过了

- Scaffold
     - Column
          - Container
               - Image

您的小部件:

Scaffold(
      body: Column(
        children: [
          Container(
            width: double.infinity,
            height: 300,
            decoration: BoxDecoration(
              image: DecorationImage(
                fit: BoxFit.fill,
                image: NetworkImage(
                  'https://cdn.pixabay.com/photo/2022/03/27/11/23/cat-7094808__340.jpg',
                ),
              ),
            ),
          ),
          //Add your other widgets here
        ],
      ),
    ),

或使用SafeArea, top 属性 false

  SafeArea(
      top: false,
      child: Container(),
    ),

结果屏幕->

 Scaffold(
        body: SafeArea(
          top: false,
          bottom: false,
          child: _yourBody(),
        ),

为什么要使用 SafeArea :

SafeArea class 空安全。通过足够的填充来插入其子项以避免操作系统入侵的小部件。例如,这将使子项缩进足够多以避免屏幕顶部的状态栏。