Interface SplashScreen

  • All Known Implementing Classes:

    public interface SplashScreen
    Splash screen configuration for a given Flutter experience.

    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).

    Please use the new Splash screen API available on Android S. On lower versions of Android, it's no longer necessary to display a splash screen to wait for the Flutter first frame.

    • Method Detail

      • createSplashView

        View createSplashView​(@NonNull
                              Context context,
                              Bundle savedInstanceState)
        Creates a 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.

        context - The current context. e.g. The activity.
        savedInstanceState - If the activity is being re-initialized after previously being shut down then this Bundle contains the data it most recently supplied in onSaveInstanceState(Bundle).
        The splash screen view.
      • transitionToFlutter

        void transitionToFlutter​(@NonNull
                                 Runnable onTransitionComplete)
        Invoked by Flutter when Flutter has rendered its first frame, and would like the 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.

        onTransitionComplete - The callback after the transition has completed.
      • doesSplashViewRememberItsTransition

        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. Returns false otherwise.

        The typical return value for this method is false. When the return value is false, the following can happen:

        1. Splash View begins transitioning to the Flutter UI.
        2. A configuration change occurs, like an orientation change, and the Activity is re-created, along with the View hierarchy.
        3. The remainder of the splash transition is skipped and the Flutter UI is displayed.
        In the vast majority of cases, skipping a little bit of the splash transition should be acceptable. Most users will never experience such a situation, and those that do are unlikely to notice the visual artifact. However, a workaround is available for those developers who need it.

        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.

        True if the given splash View should be displayed in the View hierarchy.
      • saveSplashScreenState

        default Bundle saveSplashScreenState()
        Returns whatever state is necessary to restore a splash View after destruction and recreation, e.g., orientation change.
        Bundle used to restore a splash screen state.