【问题标题】:Flutter WebView Plugin - How To Handle Local Storage VariablesFlutter WebView 插件 - 如何处理本地存储变量
【发布时间】:2018-09-04 19:46:42
【问题描述】:

背景:我正在开发一个使用 WebViewScaffold 加载在线目录的移动应用程序。这个特定的目录提供了初次访问的导览。

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

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

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,
    );
  }
}

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

【问题讨论】:

    标签: dart flutter mobile-development


    【解决方案1】:

    【讨论】:

    • 能否请您详细说明如何使用此插件在 webview 中设置本地存储?我找不到说明。我为此创建了question,但找不到帮助。如果您能看一看,我将不胜感激。非常感谢
    • 对不起,我自己还没试过。我猜 jparound30 添加这个功能是因为他需要它,所以我认为它对他有用。你可以给github.com/dart-flitter/flutter_webview_plugin/pull/51添加评论,看看他有没有回复。
    猜你喜欢
    • 2018-11-30
    • 2020-06-05
    • 1970-01-01
    • 2020-06-13
    • 2012-12-10
    • 2020-11-28
    • 2017-08-21
    • 1970-01-01
    • 2020-08-10
    相关资源
    最近更新 更多