Flutter 应用程序在屏幕锁定时始终打开

fua*_*yah 2 android dart 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(),
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

blu*_*way 5

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

android:showWhenLocked="false"
Run Code Online (Sandbox Code Playgroud)