3

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.

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?

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.

PityTheFool
  • 298
  • 1
  • 3
  • 11

1 Answers1

0

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

enter image description here

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • Could you please elaborate on how to use this plugin to set local storage in webview? I can't find the instruction. I created a [question](https://stackoverflow.com/questions/50960945/flutter-webivew-how-to-set-local-storage) on this but I can't find help. I would really appreciate it if you could take a look. Many thanks – Tran Triet Jun 22 '18 at 08:56
  • 1
    Sorry, I haven't tried it myself yet. I guess jparound30 added this feature because he needed it, so I assume it works for him. You could add a comment to https://github.com/dart-flitter/flutter_webview_plugin/pull/51 and see if he responds. – Günter Zöchbauer Jun 22 '18 at 09:09