背景:我正在开发一个移动应用程序,其中使用 WebViewScaffold 加载在线目录。此特定目录提供初次访问时的导游服务。
问题:每次我导航到目录 WebView 时,游览都会从头开始(这会冻结用户,直到游览完成)。我怎样才能避免这种情况发生?当我在浏览器中打开目录时,游览的状态将保存在浏览器的本地存储变量中。有没有办法在flutter中保存或重置本地存储变量?
代码:单击按钮后,我会推送一条新路线,在其中创建一个新的目录对象,如下所示:
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,
);
}
}
注意:如果需要提供更多信息,请告诉我。