text stringlengths 1 372 |
|---|
and you run the app on 2.5 or later, the app might crash. |
for more info, see the deprecated splash screen API migration guide. |
info note |
for apps that embed one or more flutter screens within an |
existing android app, consider |
pre-warming a FlutterEngine and reusing the |
same engine throughout your app to minimize wait |
time associated with initialization of the flutter engine. |
<topic_end> |
<topic_start> |
initializing the app |
every android app requires initialization time while the |
operating system sets up the app’s process. |
android provides the concept of a launch screen to |
display a drawable while the app is initializing. |
a drawable is an android graphic. |
to learn how to add a drawable to your |
flutter project in android studio, |
check out import drawables into your project |
in the android developer documentation. |
the default flutter project template includes a definition |
of a launch theme and a launch background. you can customize |
this by editing styles.xml, where you can define a theme |
whose windowBackground is set to the |
drawable that should be displayed as the launch screen. |
in addition, styles.xml defines a normal theme |
to be applied to FlutterActivity after the launch |
screen is gone. the normal theme background only shows |
for a very brief moment after the splash screen disappears, |
and during orientation change and activity restoration. |
therefore, it’s recommended that the normal theme use a |
solid background color that looks similar to the primary |
background color of the flutter UI. |
<topic_end> |
<topic_start> |
set up the FlutterActivity in AndroidManifest.xml |
in AndroidManifest.xml, set the theme of |
FlutterActivity to the launch theme. then, |
add a metadata element to the desired FlutterActivity |
to instruct flutter to switch from the launch theme |
to the normal theme at the appropriate time. |
the android app now displays the desired launch screen |
while the app initializes. |
<topic_end> |
<topic_start> |
android 12 |
to configure your launch screen on android 12, |
check out android splash screens. |
as of android 12, you must use the new splash screen |
API in your styles.xml file. |
consider creating an alternate resource file for android 12 and higher. |
also make sure that your background image is in line with |
the icon guidelines; |
check out android splash screens for more details. |
make sure that |
io.flutter.embedding.android.SplashScreenDrawable is |
not set in your manifest, and that provideSplashScreen |
is not implemented, as these APIs are deprecated. |
doing so causes the android launch screen to fade smoothly |
into the flutter when the |
app is launched and the app might crash. |
some apps might want to continue showing the last frame of |
the android launch screen in flutter. for example, |
this preserves the illusion of a single frame |
while additional loading continues in dart. |
to achieve this, the following |
android APIs might be helpful: |
<code_start> |
import android.os.Build; |
import android.os.Bundle; |
import android.window.SplashScreenView; |
import androidx.core.view.WindowCompat; |
import io.flutter.embedding.android.FlutterActivity; |
public class MainActivity extends FlutterActivity { |
@override |
protected void onCreate(Bundle savedInstanceState) { |
// aligns the flutter view vertically with the window. |
WindowCompat.setDecorFitsSystemWindows(getWindow(), false); |
if (build.version.sdk_int >= Build.VERSION_CODES.S) { |
// disable the android splash screen fade out animation to avoid |
// a flicker before the similar frame is drawn in flutter. |
getSplashScreen() |
.setonexitanimationlistener( |
(splashscreenview splashScreenView) -> { |
splashScreenView.remove(); |
}); |
} |
super.onCreate(savedInstanceState); |
} |
} |
<code_end> |
<code_start> |
import android.os.Build |
import android.os.Bundle |
import androidx.core.view.WindowCompat |
import io.flutter.embedding.android.FlutterActivity |
class MainActivity : FlutterActivity() { |
override fun onCreate(savedInstanceState: bundle?) { |
// aligns the flutter view vertically with the window. |
WindowCompat.setDecorFitsSystemWindows(getWindow(), false) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.