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. SyntaxError: invalid character in identifier(Python)

    在写博客时直接将博客上的代码复制运行后发现错误SyntaxError: invalid character in identifier,我以为是l(小L)写成了1,改了还是不行. 上网查了下,发现原来 ...

  3. px,em,rem的区别与用法

    别人总结的.个人觉得特别的好: http://www.w3cplus.com/css/when-to-use-em-vs-rem.html

  4. COCI 2018/2019 CONTEST #2 T4 Maja T5Sunčanje Solution

    COCI 2018/2019 CONTEST #2 T4 T5 Solution abstract 花式暴力 #2 T5 Sunčanje 题意 按顺序给你1e5个长方形(左下角坐标&& ...

  5. Cassandra最小化安装

    Cassandra最小化安装 环境 CentOS 7.2 64位 IP_address:172.27.0.8 安装包装备 [root@master ~]# ll /usr/local/src tota ...

  6. TCP断开那些事

    继上一篇后,我们再来看一下四次挥手的过程 这里其实没有必要过多阐述,一张图胜过千言万语. 与三次握手一样,四次挥手的过程中也有许多扩展问题. 当然问的最多的还是:为什么要四次握手?为什么要等待2MSL ...

  7. Source Insight相关设置

    #Source Insight中按快捷键在其他编辑器中打开当前文件 "D:\Program Files\Zend\ZendStudio-5.5.0\bin\ZDE.exe"  %f ...

  8. 截取字段split

    172.0.0.1String[] splitAddress=qip.split("\\.");//--172001 String ip=splitAddress[0]+" ...

  9. js的一些注意点

    18-12-24 oninput事件: 在用户输入时触发,它是在元素值发生变化时立即触发: 该事件在 <input> 或 <textarea> 元素的值发生改变时触发. 缺陷: ...

  10. 小程序开发 easy-less 配置

    开发支付宝小程序, 不习惯直接写css 了,推动小程序的开发太低效,讲道理默认构建就应该支持less 和sass. vscode  有easy-less 插件,看下配置支持自定义扩展名. { &quo ...