androidflutterdart

Flutter/Android application locks the app automatically after building and installation


I am developing an flutter application which has the ability to pop up to screen when the app is locked thanks to Native Android. everything was fine but when I after trying to set the application icon using flutter_launcher_icons package, the application would automatically lock the phone on installation (phyisical device).

I believe that the cause of the issue is related to flutter_laucher_icons package, because when I commented the Native code for keeping the applicaiton on the top of the stack and showing it even when the app is locked, the problem remained. this is the Native code:

// in onCreate of the MainActivity.java
getWindow().addFlags(
                WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                        WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
        );

And this is the configuration for flutter_launcher_icons in pubspec.yaml:

flutter_launcher_icons:
  android: true
  ios: false
  image_path: "assets/images/logo.png"
  min_sdk_android: 21
  web:
    generate: true
    image_path: "assets/images/logo.png"
    background_color: "#FFFFFF"
    theme_color: "#FFFFFF"
  windows:
    generate: false
  macos:
    generate: false

Solution

  • the cuase of the problem was related to the flutter_launcher_icon, affter changing the configuration to the above code, everything works fine.

    flutter_launcher_icons:
      android: true
      ios: false
      remove_alpha_ios: false
      image_path: "assets/images/logo.png"
      adaptive_icon_background: "#ffffff"
      adaptive_icon_foreground: "assets/images/logo.png