Open bajajsahil opened 3 years ago
Hi Sahil,
Hope you are doing great!
PFB the resolution for the flutter issue shared earlier :
It appears that apparently when an app is resumed from the background, the Flutter engine isn't able to apply the default translucent layer for Popup and Bottomsheet and hence a black background appears (since that's the default theme). The fix is to simply manually apply this background to the activity. This can be done by overriding the getBackgroundMode() method in the launcher activity like this -
class MainActivity : FlutterFragmentActivity() { override fun configureFlutterEngine(flutterEngine: FlutterEngine) { GeneratedPluginRegistrant.registerWith(flutterEngine) } override fun getBackgroundMode(): FlutterActivityLaunchConfigs.BackgroundMode { return FlutterActivityLaunchConfigs.BackgroundMode.transparent }
Please feel free to reach us via our support channel https://developer.truecaller.com/support in case you have further issues for a faster and dedicated response.
Regards, Parth
Thanks Parth. It worked.
Hi @parth0907, this solution is causing an issue with Flutter 2.5. I am seeing black screen on the launch of the app intermittently. It could be due to the change in splash screen in 2.5 - https://flutter.dev/docs/development/ui/advanced/splash-screen
If I remove the code provided by you then I don't see this launch black screen issue but our original issue starts coming again.
Can you look? Thanks.
Hi @bajajsahil
Hope you are doing great!
Since we already have an example project in our Flutter repo, I would request you to provide the steps specific to this example project as to what changes need to be made to which file of this project for us to reproduce this.
Once you share the steps, we shall investigate this at our end.
Regards, Parth
Hi @parth0907
I am able to reproduce with example project as well.
As per Flutter 2.5, we need to remove below code from android\app\src\main\AndroidManifest.xml
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />
Now you have provided the below fix in MainActivity for the original problem.
override fun getBackgroundMode(): FlutterActivityLaunchConfigs.BackgroundMode {
return FlutterActivityLaunchConfigs.BackgroundMode.transparent
}
Behavior with your fix(Intermediate black screen is coming)
Behavior without you fix(no black screen is coming after launch screen)
Let me know if any more info is needed.
Thanks.
If TrueCaller bottom sheet is opened and during that, if we switch between apps then the screen blacks out.
Flutter Doctor
[√] Flutter (Channel stable, 1.22.4, on Microsoft Windows [Version 10.0.17134.165], locale en-IN) • Flutter version 1.22.4 at \fultter\flutter • Framework revision 1aafb3a8b9 (3 months ago), 2020-11-13 09:59:28 -0800 • Engine revision 2c956a31c0 • Dart version 2.10.4
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at \install\AndroidSDK • Platform android-30, build-tools 29.0.2 • ANDROID_HOME = \install\AndroidSDK • Java binary at: \install\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) • All Android licenses accepted.
[√] Android Studio (version 4.0) • Android Studio at \install\Android Studio • Flutter plugin version 45.1.2 • Dart plugin version 193.7361 • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] Connected device (1 available) • SM G960F (mobile) • 231173e32f027ece • android-arm64 • Android 10 (API 29)