Flutter,Android 4.4.2 中全屏模式无法正常工作

问题描述 投票:0回答:3

当我使用全屏模式时:

SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);

这是我的代码:

return Scaffold(
  body: Container(
    height: height,
    decoration: BoxDecoration(
      color: Colors.black,
    ),
    child: Column(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        Row(
          mainAxisAlignment: MainAxisAlignment.end,
          children: [
            IconButton(
              onPressed: () {},
              padding: const EdgeInsets.all(25),
              iconSize: 80.sp,
              icon: const Icon(
                Icons.miscellaneous_services_outlined,
              ),
            )
          ],
        ),
        Row(
          mainAxisAlignment: MainAxisAlignment.end,
          children: [
            Padding(
              padding: const EdgeInsets.all(18.0),
              child: Consumer(
                builder: (context, watch, child) {
                  final state = watch(loginNotifierProvider);
                  return Text(
                    state.appVersion,
                    style: Theme.of(context).textTheme.headline6,
                  );
                },
              ),
            ),
          ],
        )
      ],
    ),
  ),
);

虽然看不到导航栏,但屏幕底部有一个白条:

但是当我将容器包裹在柱中时:

return Scaffold(
  body: Column(
    children: [
      Container(
        height: height,
        decoration: BoxDecoration(
          color: Colors.black,
        ),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                IconButton(
                  onPressed: () {},
                  padding: const EdgeInsets.all(25),
                  iconSize: 80.sp,
                  icon: const Icon(
                    Icons.miscellaneous_services_outlined,
                  ),
                )
              ],
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                Padding(
                  padding: const EdgeInsets.all(18.0),
                  child: Consumer(
                    builder: (context, watch, child) {
                      final state = watch(loginNotifierProvider);
                      return Text(
                        state.appVersion,
                        style: Theme.of(context).textTheme.headline6,
                      );
                    },
                  ),
                ),
              ],
            )
          ],
        ),
      ),
    ],
  ),
);

容器占据全屏,但这会导致错误:

如何去掉这个条子?

如何让应用程序全屏显示?

这是android 4.4 api 19。

android flutter dart fullscreen
3个回答
2
投票

我现在已经解决了这个问题,如下:

SystemChrome.setEnabledSystemUIMode(
  Platform.isAndroid && androidInfo.version.sdkInt == 19
      ? SystemUiMode.manual
      : SystemUiMode.immersiveSticky,
  overlays: [SystemUiOverlay.bottom]);

当android的api版本为19时,我显示下部导航


0
投票

SingleChildScrollView
代替
Column

包裹
return Scaffold(
  body: SingleChildScrollView(
    
      Container(
        height: height,
        decoration: BoxDecoration(
          color: Colors.black,
        ),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                IconButton(
                  onPressed: () {},
                  padding: const EdgeInsets.all(25),
                  iconSize: 80.sp,
                  icon: const Icon(
                    Icons.miscellaneous_services_outlined,
                  ),
                )
              ],
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                Padding(
                  padding: const EdgeInsets.all(18.0),
                  child: Consumer(
                    builder: (context, watch, child) {
                      final state = watch(loginNotifierProvider);
                      return Text(
                        state.appVersion,
                        style: Theme.of(context).textTheme.headline6,
                      );
                    },
                  ),
                ),
              ],
            )
          ],
        ),
      ),
    
  ),
);

0
投票

我正在尝试在 android 4.4.2 (api 19) 上运行我的 flutter 应用程序,但它没有运行 应用程序已安装,但打开时崩溃

© www.soinside.com 2019 - 2024. All rights reserved.