onJsBeforeUnload property

Future<JsBeforeUnloadResponse?> Function(T controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)? onJsBeforeUnload
final

Event fired when the client should display a dialog to confirm navigation away from the current page. This is the result of the onbeforeunload javascript event. If JsBeforeUnloadResponse.handledByClient is true, WebView will assume that the client will handle the confirm dialog. If JsBeforeUnloadResponse.handledByClient is false, a default value of true will be returned to javascript to accept navigation away from the current page. The default behavior is to return false. Setting the JsBeforeUnloadResponse.action to JsBeforeUnloadResponseAction.CONFIRM will navigate away from the current page, JsBeforeUnloadResponseAction.CANCEL will cancel the navigation.

jsBeforeUnloadRequest contains the message to be displayed in the alert dialog and the of the page requesting the dialog.

Officially Supported Platforms/Implementations:

Implementation

final Future<JsBeforeUnloadResponse?> Function(
        T controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)?
    onJsBeforeUnload;