簡體   English   中英

Flutter 應用程序總是在屏幕鎖定時打開

[英]Flutter apps always opened when screen locked

只是問我的應用程序在屏幕鎖定時總是打開,並且我解鎖了,我的應用程序仍然存在,如果按后退按鈕或關閉應用程序,則顯示鎖屏。

我有什么問題嗎?

我沒有使用喚醒鎖或類似的 package。

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"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM