Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why flutter defaults to android:launchMode="singleTop"?

Tags:

flutter

After a simple flutter create my android launch mode is set to "singleTop".

<!-- android/app/src/main/AndroidManifest.xml -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application ...>
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            ...

This is awful user experience. It prevents screen split, multiple instances and maybe other desirable features.

Why is that needed? I changed it back to "standard" and saw no problems from it.

my question is: what? What will break setting it to "standard"?

like image 555
gcb Avatar asked Sep 20 '26 21:09

gcb


1 Answers

In an Android native app, an app can deep link into another app by initializing an activity.

However, when launchMode:singleTop is used in the manifest, a new activity is created when the current activity isn't at the top of the target task. This means that a new Dart entrypoint is created every time a new activity is created.

Because an activity has a 1:1 relation with a Flutter engine, there's no state synchronization between these two activities that would allow an app to skip certain screen. e.g. a login screen.

like image 197
Kalpesh Khandla Avatar answered Sep 23 '26 20:09

Kalpesh Khandla



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!