Challenge 29 : webview

hi. I’ve been trying to get through this challenge by creating a simple getter for “webView” in PhotoPageFragment and in PhotoPageActivity creating an instance of PhotoPageFragment and calling the fun to get its webView.
then I override the onBackPressed() fun to try control the history.
but when i do this i get an exception that the webView that i get from PhotoPageFragment is not initialized and the app crashes.
id thank you for your help if someone can give assistance.

Maybe it’s not relevant, but you can add this code in your onCreate in PhotoPageFragment

requireActivity()

        .onBackPressedDispatcher
        .addCallback(this, object : OnBackPressedCallback(true) {
            override fun handleOnBackPressed() {
                if (webView.canGoBack()) {
                    webView.goBack();
                } else {
                    isEnabled = false
                    requireActivity().onBackPressed()
                }
            }
        }
        )