Flutter WebView插件-如何处理本地存储变量 [英] Flutter WebView Plugin - How To Handle Local Storage Variables

查看:114
本文介绍了Flutter WebView插件-如何处理本地存储变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:我正在开发一个移动应用程序,其中使用WebViewScaffold加载在线目录.该特定目录在初次访问时提供了导览.

Background: I am working on a mobile application in which I use a WebViewScaffold to load an online directory. This particular directory provides a guided tour on initial visit.

问题:每次我导航到目录WebView时,游览从头开始(这会冻结用户,直到游览结束).我怎样才能避免这种情况发生?当我在浏览器中打开目录时,游览的状态将保存在浏览器的本地存储变量中.有没有办法在flutter中保存或重置本地存储变量?

Problem: Each time I navigate to the directory WebView, the tour starts from the beginning (which freezes the user until the tour is finished). How might I keep this from happening? When I open the directory in a browser, the status of the tour is saved in the browser's local storage variables. Is there a way to save or reset the local storage variables in flutter?

代码:单击按钮后,我将推一条新路线,在其中创建一个新的Directory对象,如下所示:

Code: Upon button click, I push a new route where I create a new Directory object which is shown below:

class MobileDirectory extends StatelessWidget {
  final _mobileDirectory = 'my.mobileDirectory.url';
  final _directoryTitle = new Text(
    'Directory',
    style: const TextStyle(
        fontSize: 17.0, color: Colors.white, fontWeight: FontWeight.w400),
  );
  final _backgroundColor = new Color.fromRGBO(29, 140, 186, 1.0);
  final _backButton = new BackButton(color: Colors.white);
  final _padding = new EdgeInsets.only(left: 2.0);
  final _imageAsset = new Image.asset('assets/appBar.jpg');

  @override
  Widget build(BuildContext context) {
    return new WebviewScaffold(
      appBar: new AppBar(
        leading: _backButton,
        centerTitle: true,
        backgroundColor: _backgroundColor,
        title: new Padding(
          padding: _padding,
          child: _directoryTitle,
        ),
        actions: <Widget>[
          _imageAsset,
        ],
      ),
      url: _mobileDirectory,
    );
  }
}

注意:如果需要提供更多信息,请告诉我.

Note: Please let me know if more information should be provided.

推荐答案

最新版本0.1.4支持使用localstorage

The most recent version 0.1.4 supports using localstorage

https://github.com. /dart-flitter/flutter_webview_plugin/blob/9873b2d9a2167f76018d4f6e7fc6e2a1ed8ce5c9/lib/src/webview_scaffold.dart#L35

这篇关于Flutter WebView插件-如何处理本地存储变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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