Kadri Nadir
Kadri Nadir

Reputation: 349

Flutter-web Webview use multiple LocalStorage management

Hello i do have a problem using Webviews in my Webapp case use : Dashboard, which is loading multiple Webviews where each Webview with each local storage is merged with the main local storage.

first problem : i had to use the easywebview package to solve my loading webviews issues of a webview on chrome, but i would like to use webview package.

second problem : Whene i used my chrome app with an easywebview loading inside of it i had two localstorage running independantly i wish that i can merge all my localstorages in the dashboard one.

code sample

import 'package:easy_web_view/easy_web_view.dart';
class LoginFrameWidget extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Container(
        height: double.infinity,
        width: double.infinity,
        child: EasyWebView(
          src: "http://localhost:5111/",
          isHtml: false,
          isMarkdown: false,
          convertToWidgets: false,
          onLoaded: () {},
        ));
  }
}

Image of the localstorages: localstorages

Solution needed: make one main LocalStorage using webviews instead of easywebview (if possible)

Upvotes: 0

Views: 1006

Answers (1)

Kadri Nadir
Kadri Nadir

Reputation: 349

after some research i ended up with a different solutions:

 //setup iframe
_iframeElement.height = '500';
_iframeElement.width = '500';
//listen to iframe (window.post.message)
window.onMessage.listen((event) {
  print(event.data);
  //some localstorage logic
});
_iframeElement.src = 'path';
_iframeElement.style.border = 'none';

// ignore: undefined_prefixed_name
ui.platformViewRegistry.registerViewFactory(
  'iframeElement',
  (int viewId) => _iframeElement,
);

_iframeWidget = HtmlElementView(
  key: UniqueKey(),
  viewType: 'iframeElement',
);

and than i just passed the collected data on queries
if there is a better solution i would listen to that.

Upvotes: 2

Related Questions