setOnExitAnimationListener not getting called

Viewed 18

I'm trying to add a video to the splash screen in a flutter. I was following the example provided by the flutter team. Everything Is working fine but setOnExitAnimationListener not getting called. I'm a core flutter developer. I have tried everything I found on StackOverflow or medium blogs to solve this problem.

class MainActivity: FlutterActivity() {
 private lateinit var videoView : VideoView
 private lateinit var splashScreen: SplashScreen
 private var videoDuration : Int? = null

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    // This activity will be handling the splash screen transition.
     splashScreen = installSplashScreen()

    // The content view needs to be set before calling setOnExitAnimationListener
    // to ensure that the SplashScreenView is attached to the right view root.
    val rootLayout = findViewById<FrameLayout>(android.R.id.content)
    View.inflate(this, R.layout.activity_main, rootLayout)

    videoView= findViewById(R.id.videoView)
    videoView.setVideoPath("android.resource://"+packageName+"/"+ R.raw.test_video)
    videoView.setMediaController(null)
    videoDuration = videoView.duration
    videoView.start()

    splashScreen.setOnExitAnimationListener{
            splashScreenViewProvider->
        println("Hello World Not Working")
        // Create your custom animation.
        val slideUp = ObjectAnimator.ofFloat(
            splashScreenViewProvider.view,
            View.TRANSLATION_Y,
            0f,
            -splashScreenViewProvider.view.height.toFloat()
        )
        slideUp.interpolator = AnticipateInterpolator()
        slideUp.duration = 500L

        // Call SplashScreenView.remove at the end of your custom animation.
        slideUp.doOnEnd { splashScreenViewProvider.remove() }

        // Run your animation.
        slideUp.start()
    }
}

}

I'm definitely doing something wrong but unable to find out what's the mistake.

0 Answers
Related