Flutter应用程序总是在屏幕锁定时打开



只是询问当屏幕被锁定时,我的应用程序一直打开,我解锁了,我的程序仍然有效,如果按下后退按钮或关闭应用程序,就会显示锁屏。

我有什么不对劲吗?

我没有使用唤醒锁或类似的软件包。

颤振2.0.1版

这是我的main.dart 代码

Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(
GetMaterialApp(
home: MyApp(),
debugShowCheckedModeBanner: false,
theme: ThemeData(
textTheme: GoogleFonts.interTextTheme(),
primarySwatch: Colors.blue,
),
),
);
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
///disable automatic ui adjustment for navBar and notificationBar
WidgetsBinding.instance.renderView.automaticSystemUiAdjustment = false;
///only potrait orientation use
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
///set overlay style of NavBar and StatusBar
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark,
//        statusBarBrightness: Brightness.dark,
systemNavigationBarColor: Colors.grey.shade200,
systemNavigationBarIconBrightness: Brightness.dark,
),
);
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
textTheme: GoogleFonts.interTextTheme(
Theme.of(context).textTheme,
),
primarySwatch: Colors.blue,
),
home: PageSplashScreen(),
);
}
}

只需在AndroidManifest.xml中删除此定义或将值设置为false

android:showWhenLocked="false"

最新更新