首页 文章

Flutter WebView 插件 - 如何处理本地存储变量

提问于
浏览
2

背景:我正在开发一个移动应用程序,我在其中使用 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,
    );
  }
}

注意:如果有更多信息,请告诉我。

1 回答

相关问题