Flutter:离开页面时关闭Web视图 [英] Flutter: to close a webview when you left the page

查看:781
本文介绍了Flutter:离开页面时关闭Web视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个分段控件,并且在其中的一个页面中,我有一个webview.当我从分段控件更改页面时,我想自动关闭Web视图.有什么建议吗?

I have a segmented control and, in one of its pages, I have a webview. I want to close my web view automatically when I change page from the segmented control. Some suggestion?

推荐答案

您可以处理StateFullWidget的dispose事件,并在处理组件或页面时关闭Web视图:

you may work on the dispose event of your StateFullWidget and close your webview when your component or page disposed :

@override
void dispose() {
  // close the webview here
  super.dispose();
}

这篇关于Flutter:离开页面时关闭Web视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆