https://www.cnblogs.com/pjl43/p/9866753.html

https://www.jianshu.com/p/55092eb06c17

requests:

https://stackoverflow.com/questions/53101858/handling-cookies-in-flutter

heck out requests, a flutter library to help with modern RESTful http requests (basic cookies support and json)

  • as of now, it uses shared_preferences which is not the best practice (security-wise) to store sensitive data (session-ids etc) Issue #1

pubspec.yaml

dependencies:
requests: ^1.0.0

Usage:

import 'package:requests/requests.dart';

// ...

// this will persist cookies
await Requests.post("https://example.com/api/v1/login", body: {"username":"...", "password":"..."} ); // this will re-use the persisted cookies
dynamic data = await Requests.get("https://example.com/api/v1/stuff", json: true);

  

https://pub.dartlang.org/packages/dio#cookie-manager

https://github.com/fluttercommunity/flutter_webview_plugin/pull/51

Unfortunately, I was not considering operating LocalStorage from outside WebView.

Although I tried a little investigation,
there seems to be a case in which execution of evalJavascript or access to LocalStorage can not be performed normally due to the timing of WebView startup, the timing of page loading, and so on.

You may be able to avoid it by waiting until the first page loading is completed and then accessing LocalStorage with evalJavascript.

like this.

// On urlChanged stream
StreamSubscription<WebViewStateChanged> _onStateChanged;
_onStateChanged = flutterWebviewPlugin.onStateChanged.listen((WebViewStateChanged state) {
if (mounted) {
if (state.type == WebViewState.finishLoad) {
flutterWebviewPlugin.evalJavascript(
"window.localStorage.setItem('LOCAL_STORAGE','SOMETOKEN');" +
"document.getElementById('showLocalStorageBtn').click();"
);
}
}
});

i hope you will find it helpful.

webview 监听及获取cookie的更多相关文章

  1. Hibernate数据连接不能正常释放的原因,以及在监听中获取apolicationContext上下文

    Hibernate数据库连接不能正常释放: https://blog.csdn.net/u011644423/article/details/44267301 监听中获取applicationCont ...

  2. datePicker 及 timePicker 监听事件 获取用户选择 年月日分秒信息

    public class MainActivity extends AppCompatActivity { private TimePicker timePicker; private DatePic ...

  3. Jquery中input:type=radio的监听,获取设置值

    一.html <div id='demo'> <input type='radio' name='sex' value='男' > <input type='radio' ...

  4. Android中监听webview监听是否加载完成

    之前写过一篇捕获Phoengap的webview事件的方法,主要是在实现了CordovaInterface的Activity中,  在onMessage中根据第一个参数的message name来判断 ...

  5. BroadcoastReceiver之短信到来监听和获取内容

    废话就不说了,新建类继承,然后配置Manifest.xml:如下 <!--需要给一个接收短信的权限 --> <uses-permission android:name="a ...

  6. WebView使用_WebView监听网页下载_DownloadManager使用

    最近在做一个较简单的项目:通过一个webview来显示一个网页的App 这个网页有下载的功能,关于这一功能需要用到两个知识点: 1.webview监听网页的下载链接.(webview默认情况下是没有开 ...

  7. java事件监听

    获取事件监听需要获取实现ActionListener接口的方法, public class SimpleEvent extends JFrame{    private JButton jb=new ...

  8. OC - 18.监听iPhone的网络状态

    使用系统的方法来监听网络状态 系统的方法是通过通知机制来实现网络状态的监听 实现网络状态监听的步骤 定义Reachability类型的成员变量来保存网络的状态 @property (nonatomic ...

  9. 内容观察者 ContentObserver 监听短信、通话记录数据库 挂断来电

    Activity public class MainActivity extends ListActivity {     private TextView tv_info;     private  ...

随机推荐

  1. (转载)CentOS6 Linux系统添加永久静态路由的方法

    https://blog.csdn.net/magerguo/article/details/49636231

  2. vue----分级上传

    <template> <div class="page"> <div id="filePicker">选择文件</di ...

  3. 防止enter提交表单

    如何防止回车(enter)键提交表单,其实很简单,就一句话.onkeydown="if(event.keyCode==13)return false;"把这句写在from标签里面就 ...

  4. 音视频下载Chrome插件 官方主页

    2019年3月20日前的旧版有不能下载的情况,请使用下面的新版 音视频下载是个点击图标后就能下载网页里正在播放的音视频文件的软件 下载:官方下载                百度网盘     Chr ...

  5. JS数组reduce()方法详解及高级技巧

    1.语法 arr.reduce(callback,[initialValue]) reduce 为数组中的每一个元素依次执行回调函数,不包括数组中被删除或从未被赋值的元素,接受四个参数:初始值(或者上 ...

  6. WPF气泡样式弹窗效果

    页面设计需求,做了一个气泡形状的弹出框,效果如下: 设计思路如下: 1. 使用Path绘制气泡的尖尖,将这个放到顶层: 2. 在用border绘制长方形框,将这个放到底层,并且设置Margin值,使得 ...

  7. Word图片、表格添加题注

    1.首先为图片.表格添加题注: 2.通过交叉引用,如图**和图片.表的编号相关联起来:

  8. java-方法重载、参数传递、

    1.Java的方法重载overload:同一个类内,可以有多个同名的方法,只要参数不同即可(包括参数类型和个数.多类型顺序) 2.基本类型(8种:byte\short\int\long\double\ ...

  9. 定位属性position

    定位属性position小结 1.元素为fixed(固定的),则是固定定位,即使是子元素,也不参考父元素的位置,即以浏览器作为参考定位.相当于电脑屏幕的一只蚂蚁,你无论怎么滑动屏幕,还是在原来的位置. ...

  10. rpc轻量级框架实例