jar*_*ari 3 android android-immersive flutter android-12
我在 Android 12 上使用 flutter 2.5.3 时会发生这种情况
使用时
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的代码
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,
),
],
),
);
}
Run Code Online (Sandbox Code Playgroud)
我想知道我是否遗漏了一些东西
如果有人仍在寻找解决方案,请在 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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1815 次 |
| 最近记录: |