public interface SplashScreen
Implementations provide a visual representation of a splash screen in createSplashView(Context, Bundle), and implement a transition from the splash UI to Flutter's
UI in transitionToFlutter(Runnable).
| Modifier and Type | Method and Description |
|---|---|
View |
createSplashView(Context context,
Bundle savedInstanceState)
Creates a
View to be displayed as a splash screen before Flutter renders its first
frame. |
default boolean |
doesSplashViewRememberItsTransition()
Returns
true if the splash View built by this SplashScreen remembers
its transition progress across configuration changes by saving that progress to View
state. |
default Bundle |
saveSplashScreenState()
Returns whatever state is necessary to restore a splash
View after destruction and
recreation, e.g., orientation change. |
void |
transitionToFlutter(Runnable onTransitionComplete)
Invoked by Flutter when Flutter has rendered its first frame, and would like the
splashView to disappear. |
@Nullable View createSplashView(@NonNull Context context, @Nullable Bundle savedInstanceState)
View to be displayed as a splash screen before Flutter renders its first
frame.
This method can be called at any time, and may be called multiple times depending on Android configuration changes that require recreation of a view hierarchy. Implementers that provide a stateful splash view, such as one with animations, should take care to migrate that animation state from the previously returned splash view to the newly created splash view.
void transitionToFlutter(@NonNull
Runnable onTransitionComplete)
splashView to disappear.
The provided onTransitionComplete callback must be invoked when the splash View has finished transitioning itself away. The splash View will be removed and
destroyed when the callback is invoked.
default boolean doesSplashViewRememberItsTransition()
true if the splash View built by this SplashScreen remembers
its transition progress across configuration changes by saving that progress to View
state. Returns false otherwise.
The typical return value for this method is false. When the return value is false, the following can happen:
View begins transitioning to the Flutter UI.
Activity is
re-created, along with the View hierarchy.
Returning true from this method will cause the given splash View to be
displayed in the View hierarchy, even if Flutter has already rendered its first frame.
It is then the responsibility of the splash View to remember its previous transition
progress, restart any animations, and then trigger its completion callback when appropriate. It
is also the responsibility of the splash View to immediately invoke the completion
callback if it has already completed its transition. By meeting these requirements, and
returning true from this method, the splash screen experience will be completely
seamless, including configuration changes.
@Nullable default Bundle saveSplashScreenState()
View after destruction and
recreation, e.g., orientation change.